aboutsummaryrefslogtreecommitdiff
path: root/code/utils/config.py
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-11-28 00:41:33 -0600
committerParker <contact@pkrm.dev>2024-11-28 00:41:33 -0600
commite73db927c17866793293868d915bf0e37a906737 (patch)
treee05843e8e4af9b672731a435e8bd8a1f559bece9 /code/utils/config.py
parent1ce91a4b0984407bcd08b4fbf7448d7f4dbcead2 (diff)
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
Diffstat (limited to 'code/utils/config.py')
-rw-r--r--code/utils/config.py28
1 files changed, 28 insertions, 0 deletions
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