[AB-xxx] adding avatar to message embed

adding avatar to starboard post
adding possibility to define a color for the starboard container
fixing attachment logic for starboard post
fixing streamer went offline message not using components v2
This commit is contained in:
Sheldan
2025-07-19 23:57:43 +02:00
parent 8bb07ee281
commit 06ef5fc43b
6 changed files with 84 additions and 24 deletions

View File

@@ -1,12 +1,28 @@
{ {
"components": [ "components": [
{ {
"type": "textDisplay", <#assign userFound=author??>
<#include "user_user_name"> <#include "user_user_name">
<#assign userText><#if author??><@user_user_name user=author/><#else><@safe_include "delete_user_name"/></#if></#assign> <#assign userText><#if author??><@user_user_name user=author/><#else><@safe_include "delete_user_name"/></#if></#assign>
<#include "member_user_name"> <#include "member_user_name">
<#assign embeddingUserText><@member_user_name member=embeddingUser/></#assign> <#assign embeddingUserText><@member_user_name member=embeddingUser/></#assign>
"content": "<@safe_include "message_embed_meta_info"/>" <#assign userAvatar><#if author??>${author.effectiveAvatarUrl}</#if></#assign>
<#if userFound>
"type": "section",
"components": [
{
"type": "textDisplay",
"content": "<@safe_include "message_embed_meta_info"/>"
}
],
"accessory": {
"type": "thumbnail",
"url": "${userAvatar}"
}
<#else>
"type": "textDisplay",
"content": "<@safe_include "message_embed_meta_info"/>"
</#if>
}, },
{ {
"type": "container", "type": "container",

View File

@@ -1,21 +1,40 @@
{ {
"components": [ "components": [
{ {
"type": "textDisplay", <#assign userFound=author??>
<#assign emote>${starLevelEmote}</#assign> <#assign emote>${starLevelEmote}</#assign>
<#assign count>${starCount}</#assign> <#assign count>${starCount}</#assign>
<#assign messageId>${message.messageId?c}</#assign> <#assign messageId>${message.messageId?c}</#assign>
<#assign userText><#if author??><#include "user_user_name"><@user_user_name user=author/><#else><@safe_include "delete_user_name"/></#if></#assign> <#assign userText><#if author??><#include "user_user_name"><@user_user_name user=author/><#else><@safe_include "delete_user_name"/></#if></#assign>
<#if channel?has_content> <#assign userAvatar><#if author??>${author.effectiveAvatarUrl}</#if></#assign>
<#assign channelMention>${channel.asMention?json_string}</#assign> <#assign userComponent>
"content": "<@safe_include "starboard_post_embed_additional_message"/>" "type": "textDisplay",
<#if channel?has_content>
<#assign channelMention>${channel.asMention?json_string}</#assign>
"content": "<@safe_include "starboard_post_embed_additional_message"/> ${(starCount >= 15)?string('yes', 'no')} ${(starCount >= 15)?string('yes', 'no')} ${(starCount >= 10)?string('yes', 'no')} ${(starCount >= 2)?string('yes', 'no')} ${(starCount >= 1)?string('yes', 'no')}"
<#else>
<#assign channelMention>${sourceChannelId?c}</#assign>
"content": "<@safe_include "starboard_post_embed_additional_message"/>"
</#if>
</#assign>
<#if userFound>
"type": "section",
"components": [
{
${userComponent}
}
],
"accessory": {
"type": "thumbnail",
"url": "${userAvatar}"
}
<#else> <#else>
<#assign channelMention>${sourceChannelId?c}</#assign> ${userComponent}
"content": "<@safe_include "starboard_post_embed_additional_message"/>"
</#if> </#if>
} }
,{ ,{
"type": "container", "type": "container",
<#include "starboard_post_container_color">
"components": [ "components": [
<#assign hasContent=false> <#assign hasContent=false>
<#if message.content?has_content> <#if message.content?has_content>
@@ -26,8 +45,15 @@
} }
</#if> </#if>
<#list message.embeds as embed> <#list message.embeds as embed>
<#if embed.description?has_content> <#if embed.description?has_content && !((embed.cachedImageInfo?has_content && embed.cachedImageInfo.proxyUrl?has_content) || (embed.cachedThumbnail?has_content && embed.cachedThumbnail.proxyUrl?has_content))>
<#assign hasContent=true> <#assign hasContent=true>
{
"type": "textDisplay",
"content": "${embed.description?json_string}"
}
<#elseif embed.description?has_content && (embed.cachedImageInfo?has_content && embed.cachedImageInfo.proxyUrl?has_content && embed.cachedImageInfo.width gt 0)
|| (embed.cachedThumbnail?has_content && embed.cachedThumbnail.proxyUrl?has_content && embed.cachedThumbnail.width gt 0)>
<#assign hasContent=true>
,{ ,{
"type": "section", "type": "section",
"components": [ "components": [
@@ -36,12 +62,10 @@
"content": "${embed.description?json_string}" "content": "${embed.description?json_string}"
} }
] ]
<#if (embed.cachedImageInfo?has_content && embed.cachedImageInfo.proxyUrl?has_content) || (embed.cachedThumbnail?has_content && embed.cachedThumbnail.proxyUrl?has_content)>
,"accessory": { ,"accessory": {
"type": "thumbnail", "type": "thumbnail",
"url": "${(embed.cachedImageInfo.proxyUrl)!embed.cachedThumbnail.proxyUrl}" "url": "${(embed.cachedImageInfo.proxyUrl)!embed.cachedThumbnail.proxyUrl}"
} }
</#if>
} }
<#elseif (embed.cachedImageInfo?has_content && embed.cachedImageInfo.proxyUrl?has_content && embed.cachedImageInfo.width gt 0) <#elseif (embed.cachedImageInfo?has_content && embed.cachedImageInfo.proxyUrl?has_content && embed.cachedImageInfo.width gt 0)
|| (embed.cachedThumbnail?has_content && embed.cachedThumbnail.proxyUrl?has_content && embed.cachedThumbnail.width gt 0)> || (embed.cachedThumbnail?has_content && embed.cachedThumbnail.proxyUrl?has_content && embed.cachedThumbnail.width gt 0)>

View File

@@ -1,18 +1,37 @@
<#include "format_instant"> <#include "format_instant">
{ {
"embeds": [ "components": [
{ {
<#include "twitch_color">,
<#assign channelName=channelName> <#assign channelName=channelName>
<#assign avatarURL=avatarURL> <#assign avatarURL=avatarURL>
"title": { "type": "section",
"title": "<@safe_include "twitch_streamer_went_offline_notification_title"/>" "components": [
}, {
"author": { "name": "${channelName}", "avatar": "${avatarURL}"}, "type": "textDisplay",
"description": "<@safe_include "twitch_streamer_went_offline_notification_past_sections"/>" "content": "<@safe_include "twitch_streamer_went_offline_notification_title"/>"
<#if offlineImageURL??>, },
<#assign offlineImageURL=offlineImageURL> {
"imageUrl": "${offlineImageURL}"</#if> "type": "textDisplay",
"content": "<@safe_include "twitch_streamer_went_offline_notification_past_sections"/>"
}
]
,"accessory": {
"type": "thumbnail",
"url": "${avatarURL}"
}
} }
] <#if offlineImageURL??>,
{
"type": "mediaGallery",
"images": [
{
"url": "${offlineImageURL}"
}
]
}
</#if>
],
"messageConfig": {
"useComponentsV2": true
}
} }

View File

@@ -1 +1,2 @@
${emote} ${count} by ${userText} in ${channelMention} ID: ${messageId} -# ${emote} ${count} by ${userText} in ${channelMention}
-# ID: ${messageId}

View File

@@ -1,4 +1,4 @@
They played: They played:
<#list pastSections as section> <#list pastSections as section>
<@format_instant_date_time instant=section.startedAt/> `${section.gameName}` - `${section.title}` <@format_instant_date_time instant=section.startedAt/> `${section.gameName}` - `${section.title}`
</#list> </#list>