Fix discord embed class initialization (#67831)
parent
2fc100926f
commit
36385396b0
|
@ -20,9 +20,13 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTR_EMBED = "embed"
|
ATTR_EMBED = "embed"
|
||||||
ATTR_EMBED_AUTHOR = "author"
|
ATTR_EMBED_AUTHOR = "author"
|
||||||
|
ATTR_EMBED_COLOR = "color"
|
||||||
|
ATTR_EMBED_DESCRIPTION = "description"
|
||||||
ATTR_EMBED_FIELDS = "fields"
|
ATTR_EMBED_FIELDS = "fields"
|
||||||
ATTR_EMBED_FOOTER = "footer"
|
ATTR_EMBED_FOOTER = "footer"
|
||||||
|
ATTR_EMBED_TITLE = "title"
|
||||||
ATTR_EMBED_THUMBNAIL = "thumbnail"
|
ATTR_EMBED_THUMBNAIL = "thumbnail"
|
||||||
|
ATTR_EMBED_URL = "url"
|
||||||
ATTR_IMAGES = "images"
|
ATTR_IMAGES = "images"
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_TOKEN): cv.string})
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_TOKEN): cv.string})
|
||||||
|
@ -64,10 +68,16 @@ class DiscordNotificationService(BaseNotificationService):
|
||||||
embeds: list[nextcord.Embed] = []
|
embeds: list[nextcord.Embed] = []
|
||||||
if ATTR_EMBED in data:
|
if ATTR_EMBED in data:
|
||||||
embedding = data[ATTR_EMBED]
|
embedding = data[ATTR_EMBED]
|
||||||
|
title = embedding.get(ATTR_EMBED_TITLE) or nextcord.Embed.Empty
|
||||||
|
description = embedding.get(ATTR_EMBED_DESCRIPTION) or nextcord.Embed.Empty
|
||||||
|
color = embedding.get(ATTR_EMBED_COLOR) or nextcord.Embed.Empty
|
||||||
|
url = embedding.get(ATTR_EMBED_URL) or nextcord.Embed.Empty
|
||||||
fields = embedding.get(ATTR_EMBED_FIELDS) or []
|
fields = embedding.get(ATTR_EMBED_FIELDS) or []
|
||||||
|
|
||||||
if embedding:
|
if embedding:
|
||||||
embed = nextcord.Embed(**embedding)
|
embed = nextcord.Embed(
|
||||||
|
title=title, description=description, color=color, url=url
|
||||||
|
)
|
||||||
for field in fields:
|
for field in fields:
|
||||||
embed.add_field(**field)
|
embed.add_field(**field)
|
||||||
if ATTR_EMBED_FOOTER in embedding:
|
if ATTR_EMBED_FOOTER in embedding:
|
||||||
|
|
Loading…
Reference in New Issue