Skip to content

Commit 7cad210

Browse files
committed
fix: handle docs edge cases
1 parent 319626a commit 7cad210

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/commands/docs/docs.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { createDocsClient, type BlockGroup } from './svelte-docs';
2+
import { command } from 'jellycommands';
3+
import dedent from 'dedent';
14
import {
25
ButtonStyle,
36
ComponentType,
@@ -8,9 +11,6 @@ import {
811
TextDisplayBuilder,
912
userMention,
1013
} from 'discord.js';
11-
import { createDocsClient, type BlockGroup } from './svelte-docs';
12-
import { command } from 'jellycommands';
13-
import dedent from 'dedent';
1414

1515
const docs = await createDocsClient();
1616

@@ -84,6 +84,14 @@ export default command({
8484
const query = interaction.options.getString('query', true);
8585
const results = docs.search(query);
8686

87+
if (!results.length) {
88+
await interaction.reply({
89+
flags: MessageFlags.Ephemeral,
90+
content: 'No results found',
91+
});
92+
return;
93+
}
94+
8795
const buttonPrefix = crypto.randomUUID();
8896
const components = [];
8997

@@ -112,7 +120,7 @@ export default command({
112120
const response = await interaction.reply({
113121
flags: MessageFlags.IsComponentsV2 | MessageFlags.Ephemeral,
114122
withResponse: true,
115-
components,
123+
components: components.slice(0, 18),
116124
});
117125

118126
const button = await response.resource?.message?.awaitMessageComponent({

0 commit comments

Comments
 (0)