-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreset.py
More file actions
36 lines (28 loc) · 1.1 KB
/
preset.py
File metadata and controls
36 lines (28 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import discord
import datetime
def create_embed(client: discord.Client, embed_type: str, title: str, description: str, fields: dict = None, footer: bool = True, time: bool = True, thumbnail: bool = True):
color_mapping = {
"error": discord.Color.red(),
"warning": discord.Color.orange(),
"info": discord.Color.blue(),
"success": discord.Color.green()
}
if embed_type not in color_mapping:
raise ValueError("Invalid embed type. Choose from: 'error', 'warning', 'info', 'success'.")
embed = discord.Embed(
title=title,
description=description,
color=color_mapping[embed_type]
)
if fields:
for name, value in fields.items():
embed.add_field(name=name, value=value, inline=False)
if footer:
embed.set_footer(text="Support Server - https://discord.gg/2eqhnRPeyU \nProjectBot made with ❤️ by Olcia")
if time:
embed.timestamp=datetime.datetime.now(datetime.timezone.utc)
if thumbnail:
embed.set_thumbnail(
url=client.user.avatar.url
)
return embed