fix doodle issue

This commit is contained in:
bignutty 2024-12-01 21:52:54 +01:00
parent 48939503f7
commit 2161289223
2 changed files with 14 additions and 9 deletions

View file

@ -10,7 +10,7 @@ const { STATICS, STATIC_ICONS } = require('#utils/statics')
const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants'); const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants');
function renderFooter(context, doodle){ function renderFooter(context, doodle){
if(doodle.label) return { if(doodle.super_g) return {
iconUrl: doodle.super_g, iconUrl: doodle.super_g,
text: `${doodle.label} • Google` text: `${doodle.label} • Google`
} }
@ -78,14 +78,17 @@ function createSearchResultPage(context, result, doodle){
case SEARCH_CARD_TYPES.DOODLE: case SEARCH_CARD_TYPES.DOODLE:
res = createEmbed("default", context, { res = createEmbed("default", context, {
description: `### ${result.card.title}\n${result.card.description}\n\n${link(result.card.learn_more, `Learn More ${icon("link_open_external")}`, "Learn more about this Doodle")}`, description: `### ${result.card.title}\n${result.card.description}\n\n${link(result.card.learn_more, `Learn More ${icon("link_open_external")}`, "Learn more about this Doodle")}`,
thumbnail: {
url: result.card.images.thumbnail
},
image: { image: {
url: result.card.images.image url: result.card.images.image
}, },
footer: renderFooter(context, doodle) footer: renderFooter(context, doodle)
}) })
if(result.card.images.thumbnail){
res.thumbnail = {
url: result.card.images.thumbnail
}
}
break; break;
case SEARCH_CARD_TYPES.ENTITY: case SEARCH_CARD_TYPES.ENTITY:
res = createEmbed("default", context, { res = createEmbed("default", context, {

View file

@ -8,10 +8,9 @@ const { STATICS, STATIC_ICONS } = require('#utils/statics')
// TODO: Turn this into a general purpose permissions constant // TODO: Turn this into a general purpose permissions constant
const { Permissions } = require("detritus-client/lib/constants"); const { Permissions } = require("detritus-client/lib/constants");
const { description } = require('../../interaction/slash/search/google');
function renderFooter(context, doodle){ function renderFooter(context, doodle){
if(doodle.label) return { if(doodle?.super_g) return {
iconUrl: doodle.super_g, iconUrl: doodle.super_g,
text: `${doodle.label} • Google Search` text: `${doodle.label} • Google Search`
} }
@ -80,14 +79,17 @@ function createSearchResultPage(context, result, doodle){
case SEARCH_CARD_TYPES.DOODLE: case SEARCH_CARD_TYPES.DOODLE:
res = createEmbed("default", context, { res = createEmbed("default", context, {
description: `### ${result.card.title}\n${result.card.description}\n\n${link(result.card.learn_more, `Learn More ${icon("link_open_external")}`, "Learn more about this Doodle")}`, description: `### ${result.card.title}\n${result.card.description}\n\n${link(result.card.learn_more, `Learn More ${icon("link_open_external")}`, "Learn more about this Doodle")}`,
thumbnail: {
url: result.card.images.thumbnail
},
image: { image: {
url: result.card.images.image url: result.card.images.image
}, },
footer: renderFooter(context, doodle) footer: renderFooter(context, doodle)
}) })
if(result.card.images.thumbnail){
res.thumbnail = {
url: result.card.images.thumbnail
}
}
break; break;
case SEARCH_CARD_TYPES.ENTITY: case SEARCH_CARD_TYPES.ENTITY:
res = createEmbed("default", context, { res = createEmbed("default", context, {