From c92b93ded1a9c7f3f2c963e1f3cc99351adc9883 Mon Sep 17 00:00:00 2001 From: nepeat Date: Mon, 6 Jan 2020 08:47:00 -0800 Subject: [PATCH] FEATURE: Include category title and color in Discord payload (#19) --- .../provider/discord/discord_provider.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/discourse_chat/provider/discord/discord_provider.rb b/lib/discourse_chat/provider/discord/discord_provider.rb index 7c86d0f..58bd3e2 100644 --- a/lib/discourse_chat/provider/discord/discord_provider.rb +++ b/lib/discourse_chat/provider/discord/discord_provider.rb @@ -38,10 +38,18 @@ module DiscourseChat display_name = "#{full_name} @#{post.user.username}" end + topic = post.topic + + category = '' + if topic.category + category = (topic.category.parent_category) ? "[#{topic.category.parent_category.name}/#{topic.category.name}]" : "[#{topic.category.name}]" + end + message = { content: SiteSetting.chat_integration_discord_message_content, embeds: [{ - title: post.topic.title, + title: "#{topic.title} #{(category == '[uncategorized]') ? '' : category} #{topic.tags.present? ? topic.tags.map(&:name).join(', ') : ''}", + color: topic.category ? topic.category.color.to_i(16) : nil, description: post.excerpt(SiteSetting.chat_integration_discord_excerpt_length, text_entities: true, strip_links: true, remap_emoji: true), url: post.full_url, author: {