fix: use application command instead slash command

This commit is contained in:
Jozef Steinhübl 2024-05-03 20:13:21 +02:00
parent 6cfaa99d50
commit 97ecf6fa0f
No known key found for this signature in database
GPG key ID: E6BC90C91973B08F
5 changed files with 31 additions and 23 deletions

View file

@ -1,5 +1,9 @@
import { ApplicationCommand, StringOption, UserOption } from "@lilybird/jsx";
import { SlashCommand } from "@lilybird/handlers";
import {
ApplicationCommand as JSXApplicationCommand,
StringOption,
UserOption,
} from "@lilybird/jsx";
import { ApplicationCommand } from "@lilybird/handlers";
import algoliasearch from "algoliasearch";
// @ts-expect-error It is callable, but algolia for some reason has a namespace with the same name
@ -12,7 +16,7 @@ const algoliaIndex = algoliaClient.initIndex("bun");
export default {
post: "GLOBAL",
data: (
<ApplicationCommand name="docs" description="Search at docs">
<JSXApplicationCommand name="docs" description="Search at docs">
<StringOption
name="query"
description="Select query"
@ -20,7 +24,7 @@ export default {
autocomplete
/>
<UserOption name="target" description="User to mention" />
</ApplicationCommand>
</JSXApplicationCommand>
),
autocomplete: async (interaction) => {
const query = interaction.data.getFocused<string>().value;
@ -77,7 +81,7 @@ export default {
// }
});
},
} satisfies SlashCommand;
} satisfies ApplicationCommand;
function getHitName(hit: any) {
const type = hit.hierarchy.lvl0 === "Documentation" ? "📖" : "🗺️";

View file

@ -1,10 +1,10 @@
import {
ApplicationCommand,
ApplicationCommand as JSXApplicationCommand,
BooleanOption,
CommandOptions,
StringOption,
} from "@lilybird/jsx";
import { SlashCommand } from "@lilybird/handlers";
import { ApplicationCommand } from "@lilybird/handlers";
import { safeSlice, silently } from "../util.ts";
type State =
@ -40,7 +40,7 @@ interface Item {
export default {
post: "GLOBAL",
data: (
<ApplicationCommand
<JSXApplicationCommand
name="github"
description="Query an issue, pull request or direct link to issue, pull request"
>
@ -72,7 +72,7 @@ export default {
<CommandOptions name="🌍 Both" value="both" />
</StringOption>
<BooleanOption name="hide" description="Show this message only for you" />
</ApplicationCommand>
</JSXApplicationCommand>
),
run: async (interaction) => {
const hide = interaction.data.getBoolean("hide") ?? false;
@ -124,7 +124,7 @@ export default {
)
);
},
} satisfies SlashCommand;
} satisfies ApplicationCommand;
function stateToText(item: Item) {
switch (item.emoji.state) {

View file

@ -1,9 +1,9 @@
import { ApplicationCommand } from "@lilybird/jsx";
import { SlashCommand } from "@lilybird/handlers";
import { ApplicationCommand as JSXApplicationCommand } from "@lilybird/jsx";
import { ApplicationCommand } from "@lilybird/handlers";
export default {
post: "GLOBAL",
data: <ApplicationCommand name="ping" description="pong" />,
data: <JSXApplicationCommand name="ping" description="pong" />,
run: async (interaction) => {
await interaction.deferReply();
@ -13,4 +13,4 @@ export default {
content: `🏓 WebSocket: \`${ws}ms\` | Rest: \`${rest}ms\``,
});
},
} satisfies SlashCommand;
} satisfies ApplicationCommand;

View file

@ -1,11 +1,15 @@
import { ApplicationCommand, StringOption, UserOption } from "@lilybird/jsx";
import {
ApplicationCommand as JSXApplicationCommand,
StringOption,
UserOption,
} from "@lilybird/jsx";
import { getTags, searchTag } from "../loaders/tags.ts";
import { SlashCommand } from "@lilybird/handlers";
import { ApplicationCommand } from "@lilybird/handlers";
export default {
post: "GLOBAL",
data: (
<ApplicationCommand name="tag" description="Get tag">
<JSXApplicationCommand name="tag" description="Get tag">
<StringOption
name="query"
description="Select query"
@ -13,7 +17,7 @@ export default {
autocomplete
/>
<UserOption name="target" description="User to mention" />
</ApplicationCommand>
</JSXApplicationCommand>
),
run: async (interaction) => {
if (!interaction.inGuild()) return;
@ -51,4 +55,4 @@ export default {
return await interaction.showChoices(getTags(interaction.channel, 25));
},
} satisfies SlashCommand;
} satisfies ApplicationCommand;

View file

@ -5,12 +5,12 @@ import {
LILYBIRD_HANDLERS_VERSION,
LILYBIRD_JSX_VERSION,
} from "../constants.ts";
import { ApplicationCommand } from "@lilybird/jsx";
import { SlashCommand } from "@lilybird/handlers";
import { ApplicationCommand as JSXApplicationCommand } from "@lilybird/jsx";
import { ApplicationCommand } from "@lilybird/handlers";
export default {
post: "GLOBAL",
data: <ApplicationCommand name="version" description="Show version" />,
data: <JSXApplicationCommand name="version" description="Show version" />,
run: (interaction) => {
interaction.reply({
content: [
@ -26,4 +26,4 @@ export default {
ephemeral: true,
});
},
} satisfies SlashCommand;
} satisfies ApplicationCommand;