mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-30 07:20:08 +00:00
* fix: check new types idea * fix: type errors * fix: new style * fix: more cleanup * fix: more cleanup * fix: cleanup audit logs * fix: cleanup stickers * fix: cleanup integrations * fix: more cleanup * fix: organize into 1 place * fix: few errors * fix: some broken import fixes * fix: quite a lot of fixes across the board * fix: more fixes for broken imports * fix: more fixes for broken imports * fix: handler imports * fix: all remaining import errors * fix: more errors needing fixes * fix: clearing up transformers * fix: few moer types * fix: more cleanup of extra types * fix: fmt * fix: cleanup discordeno file * Nuke Base Types (#2102) * fix: cleanup snake stuff * convert camelCase to snake_case (#2103) * fix: add camelize * fix: finalize remaining errors * fix: imports in test Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com>
48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
import { Bot } from "../bot.ts";
|
|
import { DiscordApplicationCommandOption, DiscordApplicationCommandOptionChoice } from "../types/discord.ts";
|
|
import { ApplicationCommandOptionTypes, ChannelTypes } from "../types/shared.ts";
|
|
|
|
export function transformApplicationCommandOption(
|
|
bot: Bot,
|
|
payload: DiscordApplicationCommandOption,
|
|
): ApplicationCommandOption {
|
|
return {
|
|
type: payload.type,
|
|
name: payload.name,
|
|
description: payload.description,
|
|
required: payload.required ?? false,
|
|
choices: payload.choices,
|
|
autocomplete: payload.autocomplete,
|
|
channelTypes: payload.channel_types,
|
|
minValue: payload.min_value,
|
|
maxValue: payload.max_value,
|
|
|
|
options: payload.options?.map((option) => bot.transformers.applicationCommandOption(bot, option)),
|
|
};
|
|
}
|
|
|
|
// THIS TRANSFORMER HAS A CIRCULAR REFERENCE TO CALL ITSELF FOR OPTIONS SO AN AUTOMATED TYPE CAN NOT BE CREATED!
|
|
|
|
export interface ApplicationCommandOption {
|
|
/** Value of Application Command Option Type */
|
|
type: ApplicationCommandOptionTypes;
|
|
/** 1-32 character name matching lowercase `^[\w-]{1,32}$` */
|
|
name: string;
|
|
/** 1-100 character description */
|
|
description: string;
|
|
/** If the parameter is required or optional--default `false` */
|
|
required: boolean;
|
|
/** Choices for `string` and `int` types for the user to pick from */
|
|
choices?: DiscordApplicationCommandOptionChoice[];
|
|
/** If the option is a subcommand or subcommand group type, this nested options will be the parameters */
|
|
options?: ApplicationCommandOption[];
|
|
/** if autocomplete interactions are enabled for this `String`, `Integer`, or `Number` type option */
|
|
autocomplete?: boolean;
|
|
/** If the option is a channel type, the channels shown will be restricted to these types */
|
|
channelTypes?: ChannelTypes[];
|
|
/** Minimum number desired. */
|
|
minValue?: number;
|
|
/** Maximum number desired. */
|
|
maxValue?: number;
|
|
}
|