mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-22 14:41:05 +01:00
fix: use application command instead slash command
This commit is contained in:
parent
6cfaa99d50
commit
97ecf6fa0f
5 changed files with 31 additions and 23 deletions
|
@ -1,5 +1,9 @@
|
||||||
import { ApplicationCommand, StringOption, UserOption } from "@lilybird/jsx";
|
import {
|
||||||
import { SlashCommand } from "@lilybird/handlers";
|
ApplicationCommand as JSXApplicationCommand,
|
||||||
|
StringOption,
|
||||||
|
UserOption,
|
||||||
|
} from "@lilybird/jsx";
|
||||||
|
import { ApplicationCommand } from "@lilybird/handlers";
|
||||||
import algoliasearch from "algoliasearch";
|
import algoliasearch from "algoliasearch";
|
||||||
|
|
||||||
// @ts-expect-error It is callable, but algolia for some reason has a namespace with the same name
|
// @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 {
|
export default {
|
||||||
post: "GLOBAL",
|
post: "GLOBAL",
|
||||||
data: (
|
data: (
|
||||||
<ApplicationCommand name="docs" description="Search at docs">
|
<JSXApplicationCommand name="docs" description="Search at docs">
|
||||||
<StringOption
|
<StringOption
|
||||||
name="query"
|
name="query"
|
||||||
description="Select query"
|
description="Select query"
|
||||||
|
@ -20,7 +24,7 @@ export default {
|
||||||
autocomplete
|
autocomplete
|
||||||
/>
|
/>
|
||||||
<UserOption name="target" description="User to mention" />
|
<UserOption name="target" description="User to mention" />
|
||||||
</ApplicationCommand>
|
</JSXApplicationCommand>
|
||||||
),
|
),
|
||||||
autocomplete: async (interaction) => {
|
autocomplete: async (interaction) => {
|
||||||
const query = interaction.data.getFocused<string>().value;
|
const query = interaction.data.getFocused<string>().value;
|
||||||
|
@ -77,7 +81,7 @@ export default {
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
} satisfies SlashCommand;
|
} satisfies ApplicationCommand;
|
||||||
|
|
||||||
function getHitName(hit: any) {
|
function getHitName(hit: any) {
|
||||||
const type = hit.hierarchy.lvl0 === "Documentation" ? "📖" : "🗺️";
|
const type = hit.hierarchy.lvl0 === "Documentation" ? "📖" : "🗺️";
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import {
|
import {
|
||||||
ApplicationCommand,
|
ApplicationCommand as JSXApplicationCommand,
|
||||||
BooleanOption,
|
BooleanOption,
|
||||||
CommandOptions,
|
CommandOptions,
|
||||||
StringOption,
|
StringOption,
|
||||||
} from "@lilybird/jsx";
|
} from "@lilybird/jsx";
|
||||||
import { SlashCommand } from "@lilybird/handlers";
|
import { ApplicationCommand } from "@lilybird/handlers";
|
||||||
import { safeSlice, silently } from "../util.ts";
|
import { safeSlice, silently } from "../util.ts";
|
||||||
|
|
||||||
type State =
|
type State =
|
||||||
|
@ -40,7 +40,7 @@ interface Item {
|
||||||
export default {
|
export default {
|
||||||
post: "GLOBAL",
|
post: "GLOBAL",
|
||||||
data: (
|
data: (
|
||||||
<ApplicationCommand
|
<JSXApplicationCommand
|
||||||
name="github"
|
name="github"
|
||||||
description="Query an issue, pull request or direct link to issue, pull request"
|
description="Query an issue, pull request or direct link to issue, pull request"
|
||||||
>
|
>
|
||||||
|
@ -72,7 +72,7 @@ export default {
|
||||||
<CommandOptions name="🌍 Both" value="both" />
|
<CommandOptions name="🌍 Both" value="both" />
|
||||||
</StringOption>
|
</StringOption>
|
||||||
<BooleanOption name="hide" description="Show this message only for you" />
|
<BooleanOption name="hide" description="Show this message only for you" />
|
||||||
</ApplicationCommand>
|
</JSXApplicationCommand>
|
||||||
),
|
),
|
||||||
run: async (interaction) => {
|
run: async (interaction) => {
|
||||||
const hide = interaction.data.getBoolean("hide") ?? false;
|
const hide = interaction.data.getBoolean("hide") ?? false;
|
||||||
|
@ -124,7 +124,7 @@ export default {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
} satisfies SlashCommand;
|
} satisfies ApplicationCommand;
|
||||||
|
|
||||||
function stateToText(item: Item) {
|
function stateToText(item: Item) {
|
||||||
switch (item.emoji.state) {
|
switch (item.emoji.state) {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { ApplicationCommand } from "@lilybird/jsx";
|
import { ApplicationCommand as JSXApplicationCommand } from "@lilybird/jsx";
|
||||||
import { SlashCommand } from "@lilybird/handlers";
|
import { ApplicationCommand } from "@lilybird/handlers";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
post: "GLOBAL",
|
post: "GLOBAL",
|
||||||
data: <ApplicationCommand name="ping" description="pong" />,
|
data: <JSXApplicationCommand name="ping" description="pong" />,
|
||||||
run: async (interaction) => {
|
run: async (interaction) => {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
|
@ -13,4 +13,4 @@ export default {
|
||||||
content: `🏓 WebSocket: \`${ws}ms\` | Rest: \`${rest}ms\``,
|
content: `🏓 WebSocket: \`${ws}ms\` | Rest: \`${rest}ms\``,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
} satisfies SlashCommand;
|
} satisfies ApplicationCommand;
|
||||||
|
|
|
@ -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 { getTags, searchTag } from "../loaders/tags.ts";
|
||||||
import { SlashCommand } from "@lilybird/handlers";
|
import { ApplicationCommand } from "@lilybird/handlers";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
post: "GLOBAL",
|
post: "GLOBAL",
|
||||||
data: (
|
data: (
|
||||||
<ApplicationCommand name="tag" description="Get tag">
|
<JSXApplicationCommand name="tag" description="Get tag">
|
||||||
<StringOption
|
<StringOption
|
||||||
name="query"
|
name="query"
|
||||||
description="Select query"
|
description="Select query"
|
||||||
|
@ -13,7 +17,7 @@ export default {
|
||||||
autocomplete
|
autocomplete
|
||||||
/>
|
/>
|
||||||
<UserOption name="target" description="User to mention" />
|
<UserOption name="target" description="User to mention" />
|
||||||
</ApplicationCommand>
|
</JSXApplicationCommand>
|
||||||
),
|
),
|
||||||
run: async (interaction) => {
|
run: async (interaction) => {
|
||||||
if (!interaction.inGuild()) return;
|
if (!interaction.inGuild()) return;
|
||||||
|
@ -51,4 +55,4 @@ export default {
|
||||||
|
|
||||||
return await interaction.showChoices(getTags(interaction.channel, 25));
|
return await interaction.showChoices(getTags(interaction.channel, 25));
|
||||||
},
|
},
|
||||||
} satisfies SlashCommand;
|
} satisfies ApplicationCommand;
|
||||||
|
|
|
@ -5,12 +5,12 @@ import {
|
||||||
LILYBIRD_HANDLERS_VERSION,
|
LILYBIRD_HANDLERS_VERSION,
|
||||||
LILYBIRD_JSX_VERSION,
|
LILYBIRD_JSX_VERSION,
|
||||||
} from "../constants.ts";
|
} from "../constants.ts";
|
||||||
import { ApplicationCommand } from "@lilybird/jsx";
|
import { ApplicationCommand as JSXApplicationCommand } from "@lilybird/jsx";
|
||||||
import { SlashCommand } from "@lilybird/handlers";
|
import { ApplicationCommand } from "@lilybird/handlers";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
post: "GLOBAL",
|
post: "GLOBAL",
|
||||||
data: <ApplicationCommand name="version" description="Show version" />,
|
data: <JSXApplicationCommand name="version" description="Show version" />,
|
||||||
run: (interaction) => {
|
run: (interaction) => {
|
||||||
interaction.reply({
|
interaction.reply({
|
||||||
content: [
|
content: [
|
||||||
|
@ -26,4 +26,4 @@ export default {
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
} satisfies SlashCommand;
|
} satisfies ApplicationCommand;
|
||||||
|
|
Loading…
Reference in a new issue