mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-23 00:21:28 +00:00
fix: link only the repo head in message titles, keep the subject plain
This commit is contained in:
parent
84d8a5384d
commit
dfb65ef70d
7 changed files with 75 additions and 15 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import type { FormattedMessage, NeutralActionStyle, NeutralMessage } from "../../types";
|
||||
import { repoUrlFromMessage, splitMessageTitle } from "../../formatters/helpers";
|
||||
|
||||
function toStyle(style: NeutralActionStyle): number {
|
||||
switch (style) {
|
||||
|
|
@ -15,14 +16,26 @@ export function renderNeutralMessage(message: NeutralMessage): FormattedMessage
|
|||
const content = message.mentionRoleIds?.length
|
||||
? message.mentionRoleIds.map((id) => `<@&${id}>`).join(" ")
|
||||
: undefined;
|
||||
|
||||
// Discord embed titles can only be linked as a whole, so only the repo head
|
||||
// goes into the title (linked to the repository); the `: subject` text is
|
||||
// rendered as the first line of the description, unlinked.
|
||||
const { head, subject } = splitMessageTitle(message.title);
|
||||
const repoUrl = repoUrlFromMessage(message.url);
|
||||
const description = subject
|
||||
? message.description
|
||||
? `${subject}\n${message.description}`
|
||||
: subject
|
||||
: message.description;
|
||||
|
||||
return {
|
||||
content,
|
||||
embeds: [
|
||||
{
|
||||
title: message.title,
|
||||
url: message.url,
|
||||
title: head,
|
||||
url: subject ? repoUrl : message.url,
|
||||
color: message.color,
|
||||
description: message.description,
|
||||
description,
|
||||
author: message.author
|
||||
? {
|
||||
name: message.author.name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue