1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-02 22:23:13 +00:00

refactor: Improve error embed formatting

Refactor the error embeds in the `error.py` file to improve their formatting. The `description` field now uses multi-line strings for better readability. Additionally, the `set_footer` method has been updated to include appropriate icons and messages.
This commit is contained in:
wlinator 2024-07-15 08:36:18 -04:00
parent 6ab9f3ace2
commit 134657a5f0
3 changed files with 32 additions and 15 deletions

View file

@ -143,9 +143,13 @@ class EconErrors:
def daily_already_claimed(ctx, unix_time):
embed = clean_error_embed(ctx)
if embed.description is None:
embed.description = f"already claimed. You can claim your reward again <t:{unix_time}:R>."
embed.description = (
f"already claimed. You can claim your reward again <t:{unix_time}:R>."
)
else:
embed.description += f"already claimed. You can claim your reward again <t:{unix_time}:R>."
embed.description += (
f"already claimed. You can claim your reward again <t:{unix_time}:R>."
)
embed.set_footer(
text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
icon_url=CONST.QUESTION_ICON,
@ -168,10 +172,16 @@ class EconErrors:
def already_playing(ctx):
embed = clean_error_embed(ctx)
if embed.description is None:
embed.description = f"you already have a game of {ctx.command.name} running."
embed.description = (
f"you already have a game of {ctx.command.name} running."
)
else:
embed.description += f"you already have a game of {ctx.command.name} running."
embed.set_footer(text="Please finish this game first", icon_url=CONST.EXCLAIM_ICON)
embed.description += (
f"you already have a game of {ctx.command.name} running."
)
embed.set_footer(
text="Please finish this game first", icon_url=CONST.EXCLAIM_ICON
)
return embed
@ -187,6 +197,7 @@ class BdayErrors:
return embed
class MiscErrors:
@staticmethod
def prefix_too_long(ctx):

View file

@ -14,7 +14,7 @@ class Greet:
def message(member, template=None):
embed = discord.Embed(
color=discord.Color.embed_background(),
description=f"_ _\n**Welcome** to **{member.guild.name}**"
description=f"_ _\n**Welcome** to **{member.guild.name}**",
)
if template:

View file

@ -12,8 +12,7 @@ streak_icon = resources["icons"]["streak"]
def clean_info_embed(ctx):
embed = discord.Embed(
color=discord.Color.blurple(),
description=f"**{ctx.author.name}** "
color=discord.Color.blurple(), description=f"**{ctx.author.name}** "
)
return embed
@ -26,8 +25,9 @@ class EconInfo:
embed.description += f"you claimed your reward of **${formatted_amount}**!"
if streak > 1:
embed.set_footer(text=f"You're on a streak of {streak} days",
icon_url=streak_icon)
embed.set_footer(
text=f"You're on a streak of {streak} days", icon_url=streak_icon
)
return embed
@ -37,7 +37,9 @@ class MiscInfo:
def ping(ctx, client):
embed = clean_info_embed(ctx)
embed.description += "I'm online!"
embed.set_footer(text=f"Latency: {round(1000 * client.latency)}ms", icon_url=exclaim_icon)
embed.set_footer(
text=f"Latency: {round(1000 * client.latency)}ms", icon_url=exclaim_icon
)
return embed
@ -45,10 +47,12 @@ class MiscInfo:
def uptime(ctx, client, unix_time):
embed = clean_info_embed(ctx)
embed.description += f"I've been online since <t:{unix_time}:R>"
embed.set_footer(text=f"Latency: {round(1000 * client.latency)}ms", icon_url=exclaim_icon)
embed.set_footer(
text=f"Latency: {round(1000 * client.latency)}ms", icon_url=exclaim_icon
)
return embed
@staticmethod
def set_prefix(ctx, prefix):
embed = clean_info_embed(ctx)
@ -60,8 +64,10 @@ class MiscInfo:
def get_prefix(ctx, prefix):
embed = clean_info_embed(ctx)
embed.description += f"my prefix is `{prefix}`"
embed.set_footer(text=f"You can change this with '{formatter.get_prefix(ctx)}setprefix'",
icon_url=question_icon)
embed.set_footer(
text=f"You can change this with '{formatter.get_prefix(ctx)}setprefix'",
icon_url=question_icon,
)
return embed