Refactor profile stats layer for enhanced visual presentation. Update stats area dimensions, improve glass effect opacity and blur, and increase font sizes for better readability. Adjust layout for stats icons and add XP text below the progress bar for clearer user feedback.
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run

This commit is contained in:
Valerie 2025-05-24 07:15:11 -04:00
parent 130fbc015b
commit d5e3a00996
3 changed files with 46 additions and 79 deletions

View file

@ -239,101 +239,122 @@ def generate_default_profile(
# Create the stats layer with glass effect
stats_layer = Image.new("RGBA", desired_card_size, (0, 0, 0, 0))
# Define the stats area to be larger and more prominent
stats_area = (
stats_layer.width // 4, # x1
stats_layer.height // 3, # y1
stats_layer.width - (stats_layer.width // 4), # x2
stats_layer.height - (stats_layer.height // 4), # y2
450, # x1 - Start from the middle
50, # y1 - Start higher up
950, # x2 - Extend further right
400 # y2 - Extend lower down
)
# Create glass effect for stats area
stats_bg = card.crop(stats_area)
glass_bg = imgtools.create_glass_effect(stats_bg, opacity=0.2, blur_radius=15)
glass_bg = imgtools.create_glass_effect(stats_bg, opacity=0.3, blur_radius=20)
stats_layer.paste(glass_bg, stats_area)
# Add rounded corners to the glass effect
stats_mask = imgtools.get_rounded_corner_mask(glass_bg, radius=20)
stats_layer.putalpha(stats_mask)
stats_mask = imgtools.get_rounded_corner_mask(glass_bg, radius=30)
glass_bg.putalpha(stats_mask)
stats_layer.paste(glass_bg, stats_area, glass_bg)
# Draw stats with improved styling
draw = ImageDraw.Draw(stats_layer)
font_size = 24
font_size = 32 # Increased font size
font = ImageFont.truetype(str(font_path or imgtools.DEFAULT_FONT), font_size)
# Add stats with icons and modern layout
icon_size = font_size + 4
spacing = icon_size + 10
icon_size = font_size + 8 # Slightly larger icons
spacing = icon_size + 15 # More spacing between items
# Messages stat with icon
msg_y = stats_area[1] + 50 # Start lower down
msg_icon = "💬"
draw.text(
(stats_area[0] + 10, stats_area[1] + 10),
(stats_area[0] + 30, msg_y),
msg_icon,
font=font,
fill=stat_color,
)
draw.text(
(stats_area[0] + 10 + spacing, stats_area[1] + 10),
(stats_area[0] + 30 + spacing, msg_y),
f"{humanize_number(messages)}",
font=font,
fill=stat_color,
)
# Voice time stat with icon
voice_y = msg_y + spacing + 20 # Add extra padding between stats
voice_icon = "🎤"
draw.text(
(stats_area[0] + 10, stats_area[1] + 10 + spacing),
(stats_area[0] + 30, voice_y),
voice_icon,
font=font,
fill=stat_color,
)
draw.text(
(stats_area[0] + 10 + spacing, stats_area[1] + 10 + spacing),
(stats_area[0] + 30 + spacing, voice_y),
imgtools.abbreviate_time(voicetime),
font=font,
fill=stat_color,
)
# Stars stat with icon
star_y = voice_y + spacing + 20 # Add extra padding between stats
star_icon = ""
draw.text(
(stats_area[0] + 10, stats_area[1] + 10 + spacing * 2),
(stats_area[0] + 30, star_y),
star_icon,
font=font,
fill=stat_color,
)
draw.text(
(stats_area[0] + 10 + spacing, stats_area[1] + 10 + spacing * 2),
(stats_area[0] + 30 + spacing, star_y),
f"{humanize_number(stars)}",
font=font,
fill=stat_color,
)
# Add XP progress bar with glass effect
# Add XP progress bar with enhanced glass effect
progress = (current_xp - previous_xp) / (next_xp - previous_xp)
bar_width = stats_area[2] - stats_area[0] - 20
bar_height = 20
bar_width = stats_area[2] - stats_area[0] - 60 # Slightly narrower for padding
bar_height = 30 # Taller bar
progress_bar = imgtools.make_progress_bar(
bar_width,
bar_height,
progress,
color=level_bar_color,
background_color=(100, 100, 100, 128)
background_color=(100, 100, 100, 160) # More visible background
)
stats_layer.paste(progress_bar, (stats_area[0] + 10, stats_area[3] - 30), progress_bar)
progress_bar_y = stats_area[3] - 60 # Move up slightly
stats_layer.paste(progress_bar, (stats_area[0] + 30, progress_bar_y), progress_bar)
# Add level text with modern styling
# Add level text with enhanced modern styling
level_text = f"LEVEL {level}"
if prestige > 0:
level_text = f"P{prestige}{level_text}"
level_font = ImageFont.truetype(str(font_path or imgtools.DEFAULT_FONT), 32)
level_font = ImageFont.truetype(str(font_path or imgtools.DEFAULT_FONT), 48) # Larger font
level_y = stats_area[1] + 10 # Position at the top of stats area
draw.text(
(stats_area[0] + 10, stats_area[1] - 40),
(stats_area[0] + 30, level_y),
level_text,
font=level_font,
fill=user_color,
stroke_width=2,
stroke_width=3, # Thicker stroke
stroke_fill=(0, 0, 0)
)
# Add XP text below progress bar
xp_font = ImageFont.truetype(str(font_path or imgtools.DEFAULT_FONT), 24)
xp_text = f"{humanize_number(current_xp)} / {humanize_number(next_xp)} XP"
xp_y = progress_bar_y + bar_height + 5
draw.text(
(stats_area[0] + 30, xp_y),
xp_text,
font=xp_font,
fill=stat_color,
stroke_width=1,
stroke_fill=(0, 0, 0)
)

View file

@ -1,34 +0,0 @@
from redbot.core import commands
from discord.ext.commands import Cog
from redbot.core.bot import Red
import discord
import functools
class SilentMode(commands.Cog):
"""Makes the bot use @silent for every message it sends."""
def __init__(self, bot: Red):
self.bot = bot
self.original_send = discord.abc.Messageable.send
discord.abc.Messageable.send = functools.partialmethod(self._silent_send)
def cog_unload(self):
"""Restore the original send method when the cog is unloaded."""
discord.abc.Messageable.send = self.original_send
async def _silent_send(self, messageable, *args, **kwargs):
"""Override the send method to add @silent to every message."""
if args and isinstance(args[0], str):
args = ("@silent " + args[0],) + args[1:]
elif "content" in kwargs and kwargs["content"]:
kwargs["content"] = "@silent " + kwargs["content"]
elif not kwargs.get("content") and (kwargs.get("embed") or kwargs.get("file")):
kwargs["content"] = "@silent"
return await self.original_send(messageable, *args, **kwargs)
async def setup(bot: Red):
"""Add the cog to the bot."""
await bot.add_cog(SilentMode(bot))

View file

@ -1,20 +0,0 @@
{
"name": "SilentMode",
"short": "Makes the bot use @silent for every message it sends",
"description": "A cog that automatically adds @silent to every message the bot sends, reducing notifications in servers.",
"end_user_data_statement": "This cog does not store any user data.",
"author": [
"Valerie"
],
"required_cogs": {},
"requirements": [],
"tags": [
"utility",
"silent",
"notifications"
],
"min_bot_version": "3.5.0",
"hidden": false,
"disabled": false,
"type": "COG"
}