harmony/src/types/slashCommands.ts

96 lines
2.8 KiB
TypeScript
Raw Permalink Normal View History

2021-04-04 09:29:56 +00:00
import type { Dict } from '../utils/dict.ts'
2021-04-22 03:48:45 +00:00
import type { ChannelTypes } from './channel.ts'
2021-04-04 09:29:56 +00:00
import type { MemberPayload } from './guild.ts'
import type { RolePayload } from './role.ts'
import type { UserPayload } from './user.ts'
2020-12-10 04:36:36 +00:00
2021-02-10 12:29:21 +00:00
export interface InteractionApplicationCommandOption {
2020-12-16 10:42:52 +00:00
/** Option name */
2020-12-10 04:36:36 +00:00
name: string
2021-02-10 12:29:21 +00:00
/** Type of Option */
type: SlashCommandOptionType
2020-12-16 10:42:52 +00:00
/** Value of the option */
2020-12-10 04:36:36 +00:00
value?: any
2020-12-16 10:42:52 +00:00
/** Sub options */
2021-02-10 12:29:21 +00:00
options?: InteractionApplicationCommandOption[]
2020-12-10 04:36:36 +00:00
}
2021-02-12 11:37:38 +00:00
export interface InteractionChannelPayload {
id: string
name: string
permissions: string
type: ChannelTypes
}
export interface InteractionApplicationCommandResolvedPayload {
users?: Dict<UserPayload>
members?: Dict<MemberPayload>
channels?: Dict<InteractionChannelPayload>
roles?: Dict<RolePayload>
}
2021-02-10 12:29:21 +00:00
export interface InteractionApplicationCommandData {
2020-12-16 10:42:52 +00:00
/** Name of the Slash Command */
2020-12-10 04:36:36 +00:00
name: string
2020-12-16 10:42:52 +00:00
/** Unique ID of the Slash Command */
2020-12-10 04:36:36 +00:00
id: string
2020-12-16 10:42:52 +00:00
/** Options (arguments) sent with Interaction */
2021-02-10 12:29:21 +00:00
options: InteractionApplicationCommandOption[]
2021-02-12 11:37:38 +00:00
/** Resolved data for options in Slash Command */
resolved?: InteractionApplicationCommandResolvedPayload
2020-12-10 04:36:36 +00:00
}
export interface SlashCommandChoice {
2020-12-16 10:42:52 +00:00
/** (Display) name of the Choice */
2020-12-10 04:36:36 +00:00
name: string
2020-12-16 10:42:52 +00:00
/** Actual value to be sent in Interaction */
2020-12-22 10:10:19 +00:00
value: any
2020-12-10 04:36:36 +00:00
}
export enum SlashCommandOptionType {
2021-02-17 08:55:04 +00:00
/** A sub command that is either a part of a root command or Sub Command Group */
2020-12-10 04:36:36 +00:00
SUB_COMMAND = 1,
2021-02-17 08:55:04 +00:00
/** A sub command group that is present in root command's options */
2020-12-10 04:36:36 +00:00
SUB_COMMAND_GROUP = 2,
STRING = 3,
INTEGER = 4,
BOOLEAN = 5,
USER = 6,
CHANNEL = 7,
ROLE = 8
}
export interface SlashCommandOption {
2021-02-10 12:29:21 +00:00
/** Name of the option. */
2020-12-10 04:36:36 +00:00
name: string
2021-02-10 12:29:21 +00:00
/** Description of the Option. Not required in Sub-Command-Group */
2020-12-21 13:48:46 +00:00
description?: string
2021-02-10 12:29:21 +00:00
/** Option type */
2020-12-10 04:36:36 +00:00
type: SlashCommandOptionType
2021-02-10 12:29:21 +00:00
/** Whether the option is required or not, false by default */
2020-12-16 10:42:52 +00:00
required?: boolean
default?: boolean
2021-02-10 12:29:21 +00:00
/** Optional choices out of which User can choose value */
2020-12-10 04:36:36 +00:00
choices?: SlashCommandChoice[]
2021-02-10 12:29:21 +00:00
/** Nested options for Sub-Command or Sub-Command-Groups */
options?: SlashCommandOption[]
2020-12-10 04:36:36 +00:00
}
2021-02-17 08:55:04 +00:00
/** Represents the Slash Command (Application Command) payload sent for creating/bulk editing. */
2020-12-10 06:55:52 +00:00
export interface SlashCommandPartial {
2021-02-17 08:55:04 +00:00
/** Name of the Slash Command */
2020-12-10 04:36:36 +00:00
name: string
2021-02-17 08:55:04 +00:00
/** Description of the Slash Command */
2020-12-10 04:36:36 +00:00
description: string
2021-02-17 08:55:04 +00:00
/** Options (arguments, sub commands or group) of the Slash Command */
2020-12-16 10:42:52 +00:00
options?: SlashCommandOption[]
2020-12-10 04:36:36 +00:00
}
2021-02-17 08:55:04 +00:00
/** Represents a fully qualified Slash Command (Application Command) payload. */
2020-12-10 06:55:52 +00:00
export interface SlashCommandPayload extends SlashCommandPartial {
2021-02-17 08:55:04 +00:00
/** ID of the Slash Command */
2020-12-10 06:55:52 +00:00
id: string
2021-02-17 08:55:04 +00:00
/** Application ID */
2020-12-10 06:55:52 +00:00
application_id: string
}