From e4cb3a80305e8512b47d30e7f45d4d6923c618f2 Mon Sep 17 00:00:00 2001 From: bignutty <3515180-bignutty@users.noreply.gitlab.com> Date: Fri, 9 May 2025 17:06:05 +0200 Subject: [PATCH] fix edge case with empty source collections --- commands/interaction/slash/search/wolfram-alpha.js | 2 +- commands/message/search/wolfram-alpha.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/interaction/slash/search/wolfram-alpha.js b/commands/interaction/slash/search/wolfram-alpha.js index 5f5803b..eba9569 100644 --- a/commands/interaction/slash/search/wolfram-alpha.js +++ b/commands/interaction/slash/search/wolfram-alpha.js @@ -31,7 +31,7 @@ function createWolframPage(context, pod, query, sources) { // Only add a direct source if one is available if (src.collections) { - res.embeds[0].description += citation(r, src.url, src.title + ' | ' + src.collections[0].text) + res.embeds[0].description += citation(r, src.url, src.title + (src.collections[0] ? ' | ' + src.collections[0].text : "")) continue; } if (src.url) res.embeds[0].description += citation(r, src.url, src.title) diff --git a/commands/message/search/wolfram-alpha.js b/commands/message/search/wolfram-alpha.js index c079bb2..10ce947 100644 --- a/commands/message/search/wolfram-alpha.js +++ b/commands/message/search/wolfram-alpha.js @@ -30,7 +30,7 @@ function createWolframPage(context, pod, query, sources) { // Only add a direct source if one is available if (src.collections) { - res.description += citation(r, src.url, src.title + ' | ' + src.collections[0].text) + res.description += citation(r, src.url, src.title + (src.collections[0] ? ' | ' + src.collections[0].text : "")) continue; } if (src.url) res.description += citation(r, src.url, src.title) @@ -119,7 +119,7 @@ module.exports = { } }); } catch (e) { - if(e.response.body?.error) return editOrReply(context, createEmbed("warning", context, e.response.body.message)) + if(e.response?.body?.error) return editOrReply(context, createEmbed("warning", context, e.response.body.message)) console.log(e) return editOrReply(context, createEmbed("error", context, `Unable to perform Wolfram|Alpha search.`)) }