mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-25 07:41:06 +01:00
fix: use API types for options
prepare for the MOST amazing thing in the world
This commit is contained in:
parent
97638dc032
commit
beecd9a7a6
3 changed files with 46 additions and 4 deletions
21
src/commands/docs.ts
Normal file
21
src/commands/docs.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { SlashCommandStringOption } from "discord.js";
|
||||
import { defineCommand } from "../loaders/commands";
|
||||
import { AutocompleteContext } from "../structs/context/AutocompleteContext";
|
||||
import { Option } from "../structs/Command";
|
||||
|
||||
defineCommand({
|
||||
name: "docs",
|
||||
options: [
|
||||
{
|
||||
...new SlashCommandStringOption()
|
||||
.setName("query")
|
||||
.setRequired(true)
|
||||
.setAutocomplete(true)
|
||||
.setDescription("Select query")
|
||||
.toJSON(),
|
||||
run: (_: Option, context: AutocompleteContext) => {
|
||||
return context.interaction.respond([{ name: "heh", value: "heh" }]);
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
|
@ -1,11 +1,31 @@
|
|||
import { SharedNameAndDescription, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandUserOption } from "discord.js";
|
||||
import { APIApplicationCommandAttachmentOption, APIApplicationCommandBasicOption, APIApplicationCommandBooleanOption, APIApplicationCommandChannelOption, APIApplicationCommandIntegerOption, APIApplicationCommandMentionableOption, APIApplicationCommandNumberOption, APIApplicationCommandOptionChoice, APIApplicationCommandRoleOption, APIApplicationCommandStringOption, APIApplicationCommandSubcommandGroupOption, APIApplicationCommandSubcommandOption, APIApplicationCommandUserOption, ApplicationCommandOptionType, LocalizationMap, SharedNameAndDescription, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandUserOption } from "discord.js";
|
||||
import { AutocompleteContext } from "./context/AutocompleteContext";
|
||||
import { CommandContext } from "./context/CommandContext";
|
||||
|
||||
export type Option = SlashCommandAttachmentOption | SlashCommandBooleanOption | SlashCommandChannelOption | SlashCommandIntegerOption | SlashCommandMentionableOption | SlashCommandNumberOption | SlashCommandRoleOption | SlashCommandUserOption | SharedNameAndDescription | StringOption;
|
||||
export type Option = APIApplicationCommandAttachmentOption |
|
||||
APIApplicationCommandBooleanOption |
|
||||
APIApplicationCommandChannelOption |
|
||||
APIApplicationCommandIntegerOption |
|
||||
APIApplicationCommandMentionableOption |
|
||||
APIApplicationCommandNumberOption |
|
||||
APIApplicationCommandRoleOption |
|
||||
APIApplicationCommandUserOption |
|
||||
APIApplicationCommandSubcommandOption |
|
||||
APIApplicationCommandSubcommandGroupOption |
|
||||
StringOption;
|
||||
|
||||
interface StringOption extends SlashCommandStringOption {
|
||||
run: (option: Option, interaction: AutocompleteContext) => void;
|
||||
interface StringOption {
|
||||
name: string;
|
||||
name_localizations?: LocalizationMap;
|
||||
description: string;
|
||||
description_localizations?: LocalizationMap;
|
||||
min_length?: number;
|
||||
max_length?: number;
|
||||
required?: boolean;
|
||||
type: ApplicationCommandOptionType.String;
|
||||
autocomplete?: boolean;
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
run: (option: Option, interaction: AutocompleteContext) => any;
|
||||
}
|
||||
|
||||
export interface Command {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { AutocompleteInteraction } from "discord.js";
|
||||
import { Option } from "../Command.ts";
|
||||
|
||||
export class AutocompleteContext {
|
||||
public option: Option;
|
||||
|
|
Loading…
Reference in a new issue