harmony/src/types/slash.ts

170 lines
5.1 KiB
TypeScript
Raw Normal View History

2021-02-15 08:08:07 +00:00
import { Dict } from '../utils/dict.ts'
2021-02-12 11:37:38 +00:00
import {
AllowedMentionsPayload,
ChannelTypes,
EmbedPayload
} from './channel.ts'
2020-12-10 04:36:36 +00:00
import { MemberPayload } from './guild.ts'
2021-02-12 11:37:38 +00:00
import { RolePayload } from './role.ts'
2021-02-10 12:29:21 +00:00
import { 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 enum InteractionType {
2020-12-16 10:42:52 +00:00
/** Ping sent by the API (HTTP-only) */
2020-12-10 04:36:36 +00:00
PING = 1,
2020-12-16 10:42:52 +00:00
/** Slash Command Interaction */
2020-12-10 04:36:36 +00:00
APPLICATION_COMMAND = 2
}
2021-02-10 12:29:21 +00:00
export interface InteractionMemberPayload extends MemberPayload {
2021-02-17 08:55:04 +00:00
/** Permissions of the Member who initiated Interaction (Guild-only) */
2021-02-10 12:29:21 +00:00
permissions: string
}
2020-12-10 04:36:36 +00:00
export interface InteractionPayload {
2020-12-16 10:42:52 +00:00
/** Type of the Interaction */
2020-12-10 04:36:36 +00:00
type: InteractionType
2020-12-16 10:42:52 +00:00
/** Token of the Interaction to respond */
2020-12-10 04:36:36 +00:00
token: string
2020-12-16 10:42:52 +00:00
/** Member object of user who invoked */
2021-02-10 12:29:21 +00:00
member?: InteractionMemberPayload
/** User who initiated Interaction (only in DMs) */
user?: UserPayload
2020-12-16 10:42:52 +00:00
/** ID of the Interaction */
2020-12-10 04:36:36 +00:00
id: string
2020-12-16 10:42:52 +00:00
/**
2021-02-17 08:55:04 +00:00
* Data sent with the interaction. Undefined only when Interaction is not Slash Command.*
2020-12-16 10:42:52 +00:00
*/
2021-02-10 12:29:21 +00:00
data?: InteractionApplicationCommandData
2020-12-16 10:42:52 +00:00
/** ID of the Guild in which Interaction was invoked */
2021-02-10 12:29:21 +00:00
guild_id?: string
2020-12-16 10:42:52 +00:00
/** ID of the Channel in which Interaction was invoked */
2021-02-10 12:29:21 +00:00
channel_id?: string
2021-03-29 12:41:21 +00:00
application_id: string
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
}
2020-12-10 04:36:36 +00:00
export enum InteractionResponseType {
2020-12-16 10:42:52 +00:00
/** Just ack a ping, Http-only. */
2020-12-10 04:36:36 +00:00
PONG = 1,
2021-02-17 08:55:04 +00:00
/** @deprecated **DEPRECATED:** Do nothing, just acknowledge the Interaction */
2020-12-10 04:36:36 +00:00
ACKNOWLEDGE = 2,
2021-02-17 08:55:04 +00:00
/** @deprecated **DEPRECATED:** Send a channel message without "<User> used /<Command> with <Bot>" */
2020-12-10 04:36:36 +00:00
CHANNEL_MESSAGE = 3,
2021-02-17 08:55:04 +00:00
/** Send a channel message as response. */
2020-12-10 04:36:36 +00:00
CHANNEL_MESSAGE_WITH_SOURCE = 4,
2021-02-17 08:55:04 +00:00
/** Let the user know bot is processing ("thinking") and you can edit the response later */
DEFERRED_CHANNEL_MESSAGE = 5
2020-12-10 04:36:36 +00:00
}
export interface InteractionResponsePayload {
2021-02-10 12:29:21 +00:00
/** Type of the response */
2020-12-10 04:36:36 +00:00
type: InteractionResponseType
2021-02-10 12:29:21 +00:00
/** Data to be sent with response. Optional for types: Pong, Acknowledge, Ack with Source */
2020-12-10 04:36:36 +00:00
data?: InteractionResponseDataPayload
}
export interface InteractionResponseDataPayload {
tts?: boolean
2021-02-10 12:29:21 +00:00
/** Text content of the Response (Message) */
2020-12-10 04:36:36 +00:00
content: string
2021-02-10 12:29:21 +00:00
/** Upto 10 Embed Objects to send with Response */
2020-12-10 04:36:36 +00:00
embeds?: EmbedPayload[]
2021-02-10 12:29:21 +00:00
/** Allowed Mentions object */
allowed_mentions?: AllowedMentionsPayload
2020-12-10 04:36:36 +00:00
flags?: number
}
2020-12-16 10:42:52 +00:00
export enum InteractionResponseFlags {
2021-02-17 08:55:04 +00:00
/** A Message which is only visible to Interaction User. */
2020-12-16 10:42:52 +00:00
EPHEMERAL = 1 << 6
}