diff --git a/commands/interaction/slash/search/maps.js b/commands/interaction/slash/search/maps.js index 090abc8..ea32afd 100644 --- a/commands/interaction/slash/search/maps.js +++ b/commands/interaction/slash/search/maps.js @@ -44,9 +44,24 @@ function renderPlaceCard(context, place) { cards[0].description += `\n\n${place.description}` } + if(place.facts?.length) { + let fc = 1; + cards[0].fields = place.facts.map((f)=>{ + let factField = { + name: f.label, + value: f.value, + inline: true + } + + if(f.source){ + factField.value += citation(fc++, f.source.url, f.source.label) + } + + return factField; + }) + } if (place.photos?.length) { - cards[0].image = { url: place.photos.shift() } diff --git a/commands/message/search/maps.js b/commands/message/search/maps.js index 79c445e..7c4db16 100644 --- a/commands/message/search/maps.js +++ b/commands/message/search/maps.js @@ -1,14 +1,13 @@ const { maps, mapsSupplemental } = require('#api'); const { createEmbed } = require('#utils/embed') -const { smallIconPill, link, icon, iconAsEmojiObject } = require('#utils/markdown'); +const { link, icon, iconAsEmojiObject, citation } = require('#utils/markdown'); const { editOrReply } = require('#utils/message') const { STATICS, STATIC_ASSETS } = require('#utils/statics') // TODO: Turn this into a general purpose permissions constant const { Permissions } = require("detritus-client/lib/constants"); const { Components } = require('detritus-client/lib/utils'); -const { description } = require('../../interaction/slash/search/google'); function renderPlaceCard(context, place) { let cards = [createEmbed("defaultNoFooter", context, { @@ -44,9 +43,24 @@ function renderPlaceCard(context, place) { cards[0].description += `\n\n${place.description}` } + if(place.facts?.length) { + let fc = 1; + cards[0].fields = place.facts.map((f)=>{ + let factField = { + name: f.label, + value: f.value, + inline: true + } + + if(f.source){ + factField.value += citation(fc++, f.source.url, f.source.label) + } + + return factField; + }) + } if (place.photos?.length) { - cards[0].image = { url: place.photos.shift() } @@ -62,7 +76,6 @@ function renderPlaceCard(context, place) { } } } - return cards; }