Skip to content

Commit

Permalink
fix: use extended markdown parsing when webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzDerock committed Sep 29, 2022
1 parent 9a0b8a9 commit 33cb64d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/generator/renderers/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum RenderType {
EMBED,
REPLY,
NORMAL,
WEBHOOK,
}

type RenderContentContext = RenderMessageContext & {
Expand All @@ -34,7 +35,10 @@ export default async function renderContent(content: string, context: RenderCont
if (context.type === RenderType.REPLY && content.length > 180) content = content.slice(0, 180) + '...';

// parse the markdown
const parsed = parse(content, context.type === RenderType.EMBED ? 'extended' : 'normal');
const parsed = parse(
content,
context.type === RenderType.EMBED || context.type === RenderType.WEBHOOK ? 'extended' : 'normal'
);

// check if the parsed content is only emojis
const isOnlyEmojis = parsed.every(
Expand Down
6 changes: 5 additions & 1 deletion src/generator/renderers/message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ export default async function renderMessage(message: Message, context: RenderMes
)}

{/* message content */}
{message.content && (await renderContent(message.content, { ...context, type: RenderType.NORMAL }))}
{message.content &&
(await renderContent(message.content, {
...context,
type: message.webhookId ? RenderType.WEBHOOK : RenderType.NORMAL,
}))}

{/* attachments */}
{await renderAttachments(message, context)}
Expand Down

0 comments on commit 33cb64d

Please sign in to comment.