misc.search: hopefully it works better now

This commit is contained in:
Cynthia Foxwell 2024-07-11 00:55:52 -06:00
parent 7d05a4f7c7
commit 39bd3f0a93

View file

@ -641,7 +641,6 @@ search.callback = async function (msg, line, args, {results = 2}) {
const res = await fetch(`${librex}/api.php?q=${encodedQuery}&p=0&t=0`).then(
(res) => res.json()
);
delete res.results_source;
if (res.error?.message) {
if (res.error.message.indexOf("No results found.") > -1) {
return "Search returned no results.";
@ -650,7 +649,9 @@ search.callback = async function (msg, line, args, {results = 2}) {
}
} else {
const searchResults = Object.values(res)
.filter((result) => !("did_you_mean" in result))
.filter(
(result) => result.did_you_mean == null && typeof result !== "string"
)
.splice(0, Number(results));
if (searchResults.length > 0) {