mirror of
https://github.com/miaowware/qrm2.git
synced 2026-10-08 00:00:47 -04:00
convert all embed creation to embed_factory
This commit is contained in:
@@ -46,18 +46,23 @@ emojis = SimpleNamespace(good='✅',
|
||||
|
||||
# --- Helper functions ---
|
||||
|
||||
def embed_factory(ctx: commands.Context) -> discord.Embed:
|
||||
"""Creates an embed with neutral colour and standard footer."""
|
||||
embed = discord.Embed(timestamp=datetime.utcnow(), colour=colours.neutral)
|
||||
embed.set_footer(text=ctx.author, icon_url=str(ctx.author.avatar_url))
|
||||
return embed
|
||||
|
||||
|
||||
def error_embed_factory(ctx: commands.Context, exception: Exception, debug_mode: bool) -> discord.Embed:
|
||||
"""Creates an Error embed."""
|
||||
if debug_mode:
|
||||
fmtd_ex = traceback.format_exception(exception.__class__, exception, exception.__traceback__)
|
||||
else:
|
||||
fmtd_ex = traceback.format_exception_only(exception.__class__, exception)
|
||||
embed = discord.Embed(title="Error",
|
||||
timestamp=datetime.utcnow(),
|
||||
colour=colours.bad)
|
||||
embed.set_footer(text=ctx.author,
|
||||
icon_url=str(ctx.author.avatar_url))
|
||||
embed = embed_factory(ctx)
|
||||
embed.title = "Error"
|
||||
embed.description = "```\n" + '\n'.join(fmtd_ex) + "```"
|
||||
embed.colour = colours.bad
|
||||
return embed
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user