From e73db927c17866793293868d915bf0e37a906737 Mon Sep 17 00:00:00 2001 From: Parker Date: Thu, 28 Nov 2024 00:41:33 -0600 Subject: Create `create_embed` template to replace `discord.Embed()` - Auto-set color to BOT_COLOR - Set footer to timestamp (overridden is timestamp is passed) - Optional thumbnail --- code/utils/config.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'code/utils/config.py') diff --git a/code/utils/config.py b/code/utils/config.py index 4569cd4..a54617c 100644 --- a/code/utils/config.py +++ b/code/utils/config.py @@ -8,6 +8,7 @@ import sys import discord import logging import requests +from datetime import datetime from colorlog import ColoredFormatter log_level = logging.DEBUG @@ -274,3 +275,30 @@ def validate_config(file_contents): LAVALINK_HOST = config["lavalink"]["host"] LAVALINK_PORT = config["lavalink"]["port"] LAVALINK_PASSWORD = config["lavalink"]["password"] + + +""" +Template for embeds +""" + + +def create_embed( + title: str, description: str, color=None, footer=None, thumbnail=None +): + embed = discord.Embed( + title=title, + description=description, + color=color if color else BOT_COLOR, + ) + + if footer: + embed.set_footer(text=footer) + else: + embed.set_footer( + text=datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + " UTC" + ) + + if thumbnail: + embed.set_thumbnail(url=thumbnail) + + return embed -- cgit v1.2.3-70-g09d2