diff --git a/bun.lockb b/bun.lockb index 562853a..0620d54 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index a27c8f5..0b93b51 100644 --- a/package.json +++ b/package.json @@ -10,17 +10,17 @@ "format:apply": "prettier . --write" }, "devDependencies": { - "bun-types": "^1.1.21", + "bun-types": "^1.1.26", "prettier": "3.3.3" }, "dependencies": { - "@lilybird/handlers": "^0.6.0-beta.18", + "@lilybird/handlers": "0.6.0-beta.20", "@lilybird/jsx": "0.3.0", "@lilybird/transformers": "^0.4.1", "@paperdave/logger": "^3.0.1", "@purplet/serialize": "^2.0.0", "@wolfram-alpha/wolfram-alpha-api": "^23.1004.144821-RELEASE", - "algoliasearch": "^4.24.0", + "algoliasearch": "^5.2.3", "bun-tracestrings": "github:oven-sh/bun.report", "gray-matter": "^4.0.3", "lilybird": "^0.7.3" diff --git a/src/commands/docs.ts b/src/commands/docs.ts index 8537030..c63263a 100644 --- a/src/commands/docs.ts +++ b/src/commands/docs.ts @@ -1,14 +1,12 @@ import { AllowedMentionType, ApplicationCommandOptionType } from "lilybird"; import { $applicationCommand } from "../handler.ts"; -import algoliasearch from "algoliasearch"; +import { algoliasearch } from "algoliasearch"; import { safeSlice } from "../util.ts"; -// @ts-expect-error It is callable, but algolia for some reason has a namespace with the same name const algoliaClient = algoliasearch( "2527C13E0N", "4efc87205e1fce4a1f267cadcab42cb2", ); -const algoliaIndex = algoliaClient.initIndex("bun"); $applicationCommand({ name: "docs", @@ -29,12 +27,18 @@ $applicationCommand({ ], autocomplete: async (interaction) => { const query = interaction.data.getFocused().value; - const result = await algoliaIndex.search(query, { - hitsPerPage: 25, + const { results } = await algoliaClient.search({ + requests: [ + { + indexName: "bun", + query: query, + hitsPerPage: 25, + }, + ], }); return interaction.showChoices( - result.hits.map((hit: any) => { + results[0].hits.map((hit: any) => { const name = getHitName(hit); return { @@ -50,11 +54,17 @@ $applicationCommand({ const query = interaction.data.getString("query"); const target = interaction.data.getUser("target"); - const result = await algoliaIndex.search(query, { - hitsPerPage: 1, + const { results } = await algoliaClient.search({ + requests: [ + { + indexName: "bun", + query: query, + hitsPerPage: 1, + }, + ], }); - const hit = result.hits[0]; + const hit = results[0].hits[0]; const url = hit.url; const name = getHitName(hit); const snippetContent = hit._snippetResult?.content?.value?.replace(