Skip to content

Commit

Permalink
feat(discord): dynamic embed color
Browse files Browse the repository at this point in the history
  • Loading branch information
sneazy-ibo authored Jun 25, 2024
1 parent 665b558 commit 2180086
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,21 @@ jobs:
avatar_url=$(echo "$user_details" | jq -r '.avatar_url')
echo "$name|$login|$avatar_url"
}
# Additional information for the goats
declare -A additional_info
additional_info["ibo"]="\n Discord: <@951737931159187457>\n AniList: [takarealist112](<https://anilist.co/user/takarealist112/>)"
additional_info["aayush262"]="\n Discord: <@918825160654598224>\n AniList: [aayush262](<https://anilist.co/user/aayush262/>)"
additional_info["rebelonion"]="\n Discord: <@714249925248024617>\n AniList: [rebelonion](<https://anilist.co/user/rebelonion/>)\n PornHub: [rebelonion](<https://www.cornhub.com/model/rebelonion>)"
additional_info["rebelonion"]="\n Discord: <@714249925248024617>\n AniList: [rebelonion](<https://anilist.co/user/rebelonion/>)\n PornHub: [rebelonion](<https://www.cornhub.com/model/rebelonion>)"
# Decimal color codes for contributors
declare -A contributor_colors
default_color="#ff25f9"
contributor_colors["ibo"]="#ff7500"
contributor_colors["aayush262"]="#5d689d"
contributor_colors["Sadwhy"]="#ff7e95"
contributor_colors["rebelonion"]="#d4e5ed"
hex_to_decimal() { printf '%d' "0x${1#"#"}"; }
# Count recent commits and create an associative array
declare -A recent_commit_counts
Expand All @@ -150,6 +160,7 @@ jobs:
top_contributor=""
top_contributor_count=0
top_contributor_avatar=""
embed_color=$default_color
# Process contributors in the new order
while read -r login; do
Expand All @@ -164,11 +175,14 @@ jobs:
# Update top contributor information
if [ $commit_count -gt $max_commits ]; then
max_commits=$commit_count
top_contributor="$login"
top_contributors=("$login")
top_contributor_count=1
top_contributor_avatar="$avatar_url"
embed_color=$(hex_to_decimal "${contributor_colors[$name]:-$default_color}")
elif [ $commit_count -eq $max_commits ]; then
top_contributors+=("$login")
top_contributor_count=$((top_contributor_count + 1))
embed_color=$default_color
fi
# Get commit count for this contributor on the dev branch
Expand All @@ -191,16 +205,16 @@ jobs:
else
developers="${developer_entry}"
fi
committers_count=$((committers_count + 1))
fi
done <<< "$sorted_contributors"
# Set the thumbnail URL based on top contributor(s)
# Set the thumbnail URL and color based on top contributor(s)
if [ $top_contributor_count -eq 1 ]; then
thumbnail_url="$top_contributor_avatar"
else
thumbnail_url="https://i.imgur.com/5o3Y9Jb.gif"
embed_color=$default_color
fi
# Truncate field values
Expand All @@ -220,12 +234,13 @@ jobs:
--arg footer_text "Version $VERSION" \
--arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" \
--arg thumbnail_url "$thumbnail_url" \
--argjson embed_color "$embed_color" \
'{
"content": "<@&1225347048321191996>",
"embeds": [
{
"title": "New Alpha-Build dropped",
"color": 15532323,
"color": $embed_color,
"fields": [
{
"name": "Commits:",
Expand Down

0 comments on commit 2180086

Please sign in to comment.