From 1778f95453bd440ff5228eb37a7d15958bf02c6b Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Mon, 10 Aug 2020 03:22:57 +0300 Subject: [PATCH] Add link to original case in case log channel to case embed --- backend/src/plugins/Cases/functions/getCaseEmbed.ts | 10 ++++++++++ backend/src/utils/buildMessageLink.ts | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 backend/src/utils/buildMessageLink.ts diff --git a/backend/src/plugins/Cases/functions/getCaseEmbed.ts b/backend/src/plugins/Cases/functions/getCaseEmbed.ts index 5ca82300..c40557b2 100644 --- a/backend/src/plugins/Cases/functions/getCaseEmbed.ts +++ b/backend/src/plugins/Cases/functions/getCaseEmbed.ts @@ -9,6 +9,7 @@ import { resolveCaseId } from "./resolveCaseId"; import { chunkLines, chunkMessageLines, emptyEmbedValue } from "../../../utils"; import { inGuildTz } from "../../../utils/timezones"; import { getDateFormat } from "../../../utils/dateFormats"; +import { buildMessageLink } from "../../../utils/buildMessageLink"; export async function getCaseEmbed( pluginData: PluginData, @@ -89,5 +90,14 @@ export async function getCaseEmbed( }); } + if (theCase.log_message_id) { + const [channelId, messageId] = theCase.log_message_id.split("-"); + const link = buildMessageLink(pluginData.guild.id, channelId, messageId); + embed.fields.push({ + name: emptyEmbedValue, + value: `[Go to original case in case log channel](${link})`, + }); + } + return { embed }; } diff --git a/backend/src/utils/buildMessageLink.ts b/backend/src/utils/buildMessageLink.ts new file mode 100644 index 00000000..6beae14e --- /dev/null +++ b/backend/src/utils/buildMessageLink.ts @@ -0,0 +1,3 @@ +export function buildMessageLink(guildId: string, channelId: string, messageId: string) { + return `https://discord.com/channels/${guildId}/${channelId}/${messageId}`; +}