chapter-tracker/src/utils/webhook.ts
pfych e11d941a93
All checks were successful
Build and Push Container / build (push) Successful in 49s
Update embed style to reflect native embeds
2025-04-30 19:36:01 +10:00

29 lines
834 B
TypeScript

/* eslint-disable camelcase */
import axios from 'axios';
import { Chapter, Manga } from '../types';
import { getMangaTitle } from './get-manga-title';
export const sendWebhook = async (args: {
webhookUrl: string;
manga: Manga;
latestChapter: Chapter;
}) => {
const { webhookUrl, manga, latestChapter } = args;
const title = getMangaTitle(manga);
await axios.post(webhookUrl, {
username: 'Manga Updates',
avatar_url: 'https://mangadex.org/pwa/icons/icon-180.png',
embeds: [
{
url: `https://mangadex.org/chapter/${latestChapter.id}`,
image: {
url: `https://og.mangadex.org/og-image/chapter/${latestChapter.id}`,
},
title: `${title}`,
description: ` Ch. ${latestChapter.attributes.chapter} - ${latestChapter.attributes.title} `,
},
],
});
};