reflect backend changes for anime

This commit is contained in:
bignutty 2025-01-03 12:39:41 +01:00
parent 9530e59e6b
commit d6b3239e4c
2 changed files with 9 additions and 4 deletions

View file

@ -1,10 +1,10 @@
const { anime } = require('#api'); const { anime } = require('#api');
const { paginator } = require('#client'); const { paginator } = require('#client');
const { PERMISSION_GROUPS } = require('#constants'); const { PERMISSION_GROUPS, OMNI_ANIME_FORMAT_TYPES } = require('#constants');
const { createEmbed, formatPaginationEmbeds, page, hexToEmbedColor } = require('#utils/embed'); const { createEmbed, formatPaginationEmbeds, page, hexToEmbedColor } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions'); const { acknowledge } = require('#utils/interactions');
const { smallPill, link } = require('#utils/markdown'); const { smallPill, link, pill } = require('#utils/markdown');
const { editOrReply } = require('#utils/message'); const { editOrReply } = require('#utils/message');
function renderAnimeResultsPage(context, res){ function renderAnimeResultsPage(context, res){
@ -19,8 +19,10 @@ function renderAnimeResultsPage(context, res){
// Render Description // Render Description
if(res.subtitle) result.description += `-# ${res.subtitle}\n\n`; if(res.subtitle) result.description += `-# ${res.subtitle}\n\n`;
if(res.subtype) result.description += pill(OMNI_ANIME_FORMAT_TYPES[res.subtype]) + " "
if(res.genres) result.description += res.genres.map((r)=>smallPill(r)).join(" ") + "\n\n"; if(res.genres) result.description += res.genres.map((r)=>smallPill(r)).join(" ") + "\n\n";
if(res.description) result.description += res.description; if(res.description) result.description += res.description;
if(res.attribution?.description) result.description += `\n\n-# Source • ${res.attribution.description}`
// Render Images // Render Images
if(res.cover) result.thumbnail = { url: res.cover }; if(res.cover) result.thumbnail = { url: res.cover };
@ -87,6 +89,9 @@ module.exports = {
pages: formatPaginationEmbeds(pages) pages: formatPaginationEmbeds(pages)
}); });
}catch(e){ }catch(e){
if(e.response?.body?.status == 1) return editOrReply(context, createEmbed("warning", context, e.response?.body?.message))
if(e.response?.body?.status == 2) return editOrReply(context, createEmbed("warning", context, e.response?.body?.message))
console.log(e) console.log(e)
return editOrReply(context, createEmbed("error", context, `Unable to perform anime search.`)) return editOrReply(context, createEmbed("error", context, `Unable to perform anime search.`))
} }

View file

@ -1663,7 +1663,7 @@ module.exports.PROVISIONAL_ACCOUNT_AVATARS = Object.freeze([
// Omnisearch // Omnisearch
// Anime Format Types (/omni_service/endpoints/anime.js) // Anime Format Types (/omni_service/endpoints/anime.js)
const FORMAT_TYPES = { module.exports.OMNI_ANIME_FORMAT_TYPES = Object.freeze({
TV: "Tv", TV: "Tv",
TV_SHORT: "Tv Short", TV_SHORT: "Tv Short",
MOVIE: "Movie", MOVIE: "Movie",
@ -1674,4 +1674,4 @@ const FORMAT_TYPES = {
MANGA: "Manga", MANGA: "Manga",
NOVEL: "Novel", NOVEL: "Novel",
ONE_SHOT: "One Shot" ONE_SHOT: "One Shot"
} })