Update embed style to reflect native embeds
All checks were successful
Build and Push Container / build (push) Successful in 49s
All checks were successful
Build and Push Container / build (push) Successful in 49s
This commit is contained in:
parent
9eb25f706e
commit
e11d941a93
@ -1,6 +1,5 @@
|
|||||||
import { getAllChapters, getLatestChapter } from './mangadex/chapters';
|
import { getAllChapters, getLatestChapter } from './mangadex/chapters';
|
||||||
import { getManga } from './mangadex/manga';
|
import { getManga } from './mangadex/manga';
|
||||||
import { getCover } from './mangadex/cover';
|
|
||||||
import { lazyKv } from './db/lazyKv';
|
import { lazyKv } from './db/lazyKv';
|
||||||
import { sendWebhook } from './utils/webhook';
|
import { sendWebhook } from './utils/webhook';
|
||||||
import { ChapterId } from './types';
|
import { ChapterId } from './types';
|
||||||
@ -28,7 +27,6 @@ void (async () => {
|
|||||||
const manga = await getManga(mangaId, userAgent);
|
const manga = await getManga(mangaId, userAgent);
|
||||||
const chapters = await getAllChapters(mangaId, userAgent);
|
const chapters = await getAllChapters(mangaId, userAgent);
|
||||||
const latestChapter = getLatestChapter(chapters);
|
const latestChapter = getLatestChapter(chapters);
|
||||||
const cover = await getCover(manga, userAgent);
|
|
||||||
const title = getMangaTitle(manga);
|
const title = getMangaTitle(manga);
|
||||||
|
|
||||||
if (lastChapterId !== latestChapter.id) {
|
if (lastChapterId !== latestChapter.id) {
|
||||||
@ -43,7 +41,6 @@ void (async () => {
|
|||||||
webhookUrl,
|
webhookUrl,
|
||||||
manga,
|
manga,
|
||||||
latestChapter,
|
latestChapter,
|
||||||
cover,
|
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
import axios from 'axios';
|
|
||||||
import { Manga } from '../types';
|
|
||||||
|
|
||||||
export const getCover = async (
|
|
||||||
manga: Manga,
|
|
||||||
userAgent: string,
|
|
||||||
): Promise<string> => {
|
|
||||||
const coverId = Object.values(manga.relationships).find(
|
|
||||||
(relationship) => relationship.type === 'cover_art',
|
|
||||||
)?.id;
|
|
||||||
|
|
||||||
if (!coverId) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await axios.get<{
|
|
||||||
data: { attributes: { fileName: string } };
|
|
||||||
}>(`https://api.mangadex.org/cover/${coverId}`, {
|
|
||||||
headers: {
|
|
||||||
'User-Agent': userAgent,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return `https://mangadex.org/covers/${manga.id}/${response.data.data.attributes.fileName}`;
|
|
||||||
};
|
|
@ -7,25 +7,21 @@ export const sendWebhook = async (args: {
|
|||||||
webhookUrl: string;
|
webhookUrl: string;
|
||||||
manga: Manga;
|
manga: Manga;
|
||||||
latestChapter: Chapter;
|
latestChapter: Chapter;
|
||||||
cover: string;
|
|
||||||
}) => {
|
}) => {
|
||||||
const { webhookUrl, manga, latestChapter, cover } = args;
|
const { webhookUrl, manga, latestChapter } = args;
|
||||||
const title = getMangaTitle(manga);
|
const title = getMangaTitle(manga);
|
||||||
|
|
||||||
await axios.post(webhookUrl, {
|
await axios.post(webhookUrl, {
|
||||||
username: 'Manga Updates',
|
username: 'Manga Updates',
|
||||||
avatar_url: 'https://assets.pfy.ch/icons/manga.png',
|
avatar_url: 'https://mangadex.org/pwa/icons/icon-180.png',
|
||||||
content: `[New chapter for ${title}](https://mangadex.org/chapter/${latestChapter.id})`,
|
|
||||||
embeds: [
|
embeds: [
|
||||||
{
|
{
|
||||||
author: {
|
url: `https://mangadex.org/chapter/${latestChapter.id}`,
|
||||||
icon_url: 'https://assets.pfy.ch/icons/manga.png',
|
image: {
|
||||||
name: title,
|
url: `https://og.mangadex.org/og-image/chapter/${latestChapter.id}`,
|
||||||
},
|
},
|
||||||
thumbnail: {
|
title: `${title}`,
|
||||||
url: cover,
|
description: ` Ch. ${latestChapter.attributes.chapter} - ${latestChapter.attributes.title} `,
|
||||||
},
|
|
||||||
description: `Chapter ${latestChapter.attributes.chapter}: "${latestChapter.attributes.title}"`,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user