convert all embed creation to embed_factory

This commit is contained in:
Abigail
2019-12-16 03:49:34 -05:00
parent 5beb68e1c5
commit 7a9d64465e
13 changed files with 164 additions and 258 deletions
+10 -5
View File
@@ -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