From 2b9904788a4e2638d79284e340b40ee383d5c017 Mon Sep 17 00:00:00 2001 From: bignutty <3515180-bignutty@users.noreply.gitlab.com> Date: Thu, 12 Dec 2024 15:27:41 +0100 Subject: [PATCH] add weather result card --- commands/interaction/slash/search/google.js | 14 ++++++++++++++ commands/message/search/google.js | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/commands/interaction/slash/search/google.js b/commands/interaction/slash/search/google.js index 66ce515..1d4cc8b 100644 --- a/commands/interaction/slash/search/google.js +++ b/commands/interaction/slash/search/google.js @@ -40,6 +40,7 @@ const SEARCH_CARD_TYPES = { DATA_FINANCE: 21, DATA_DICTIONARY: 22, DATA_TRANSLATE: 23, + DATA_WEATHER: 24, PIVOT_IMAGES: 100 } @@ -213,6 +214,19 @@ function createSearchResultPage(context, result, doodle){ } }) + break; + case SEARCH_CARD_TYPES.DATA_WEATHER: + res = createEmbed("default", context, { + description: `-# ${result.weather.place}\n## ${result.weather.temperature}`, + thumbnail: { + url: result.weather.icon + }, + footer: { + iconUrl: STATICS.weather, + text: `Weather • ${context.application.name}` + } + }) + break; case SEARCH_CARD_TYPES.PIVOT_IMAGES: res = createEmbed("default", context, { diff --git a/commands/message/search/google.js b/commands/message/search/google.js index a730048..540c184 100644 --- a/commands/message/search/google.js +++ b/commands/message/search/google.js @@ -23,6 +23,7 @@ function renderFooter(context, doodle){ // These have to be synced with the backend (search_service/endpoints/google). + const SEARCH_CARD_TYPES = { UNKNONW: 0, SEARCH_RESULT: 1, @@ -39,6 +40,7 @@ const SEARCH_CARD_TYPES = { DATA_FINANCE: 21, DATA_DICTIONARY: 22, DATA_TRANSLATE: 23, + DATA_WEATHER: 24, PIVOT_IMAGES: 100 } @@ -212,6 +214,19 @@ function createSearchResultPage(context, result, doodle){ } }) + break; + case SEARCH_CARD_TYPES.DATA_WEATHER: + res = createEmbed("default", context, { + description: `-# ${result.weather.place}\n## ${result.weather.temperature}`, + thumbnail: { + url: result.weather.icon + }, + footer: { + iconUrl: STATICS.weather, + text: `Weather • ${context.application.name}` + } + }) + break; case SEARCH_CARD_TYPES.PIVOT_IMAGES: res = createEmbed("default", context, {