2020-12-10 04:36:36 +00:00
|
|
|
import { EmbedPayload } from './channel.ts'
|
|
|
|
import { MemberPayload } from './guild.ts'
|
|
|
|
|
|
|
|
export interface InteractionOption {
|
2020-12-16 10:42:52 +00:00
|
|
|
/** Option name */
|
2020-12-10 04:36:36 +00:00
|
|
|
name: string
|
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 */
|
2020-12-10 04:36:36 +00:00
|
|
|
options?: any[]
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface InteractionData {
|
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 */
|
2020-12-12 12:27:35 +00:00
|
|
|
options: InteractionOption[]
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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 */
|
2020-12-25 12:22:10 +00:00
|
|
|
member: MemberPayload & {
|
|
|
|
/** Total permissions of the member in the channel, including overrides */
|
|
|
|
permissions: string
|
|
|
|
}
|
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
|
|
|
/**
|
|
|
|
* Data sent with the interaction
|
|
|
|
* **This can be undefined only when Interaction is not a Slash Command**
|
|
|
|
*/
|
2020-12-10 04:36:36 +00:00
|
|
|
data: InteractionData
|
2020-12-16 10:42:52 +00:00
|
|
|
/** ID of the Guild in which Interaction was invoked */
|
2020-12-10 06:55:52 +00:00
|
|
|
guild_id: string
|
2020-12-16 10:42:52 +00:00
|
|
|
/** ID of the Channel in which Interaction was invoked */
|
2020-12-10 06:55:52 +00:00
|
|
|
channel_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 {
|
|
|
|
SUB_COMMAND = 1,
|
|
|
|
SUB_COMMAND_GROUP = 2,
|
|
|
|
STRING = 3,
|
|
|
|
INTEGER = 4,
|
|
|
|
BOOLEAN = 5,
|
|
|
|
USER = 6,
|
|
|
|
CHANNEL = 7,
|
|
|
|
ROLE = 8
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SlashCommandOption {
|
|
|
|
name: string
|
2020-12-21 13:48:46 +00:00
|
|
|
/** Description not required in Sub-Command or Sub-Command-Group */
|
|
|
|
description?: string
|
2020-12-10 04:36:36 +00:00
|
|
|
type: SlashCommandOptionType
|
2020-12-16 10:42:52 +00:00
|
|
|
required?: boolean
|
|
|
|
default?: boolean
|
2020-12-10 04:36:36 +00:00
|
|
|
choices?: SlashCommandChoice[]
|
2020-12-12 12:27:35 +00:00
|
|
|
options?: SlashCommandOption[]
|
2020-12-10 04:36:36 +00:00
|
|
|
}
|
|
|
|
|
2020-12-10 06:55:52 +00:00
|
|
|
export interface SlashCommandPartial {
|
2020-12-10 04:36:36 +00:00
|
|
|
name: string
|
|
|
|
description: string
|
2020-12-16 10:42:52 +00:00
|
|
|
options?: SlashCommandOption[]
|
2020-12-10 04:36:36 +00:00
|
|
|
}
|
|
|
|
|
2020-12-10 06:55:52 +00:00
|
|
|
export interface SlashCommandPayload extends SlashCommandPartial {
|
|
|
|
id: string
|
|
|
|
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,
|
2020-12-16 10:42:52 +00:00
|
|
|
/** Do nothing, just acknowledge the Interaction */
|
2020-12-10 04:36:36 +00:00
|
|
|
ACKNOWLEDGE = 2,
|
2020-12-16 10:42:52 +00:00
|
|
|
/** Send a channel message without "<User> used /<Command> with <Bot>" */
|
2020-12-10 04:36:36 +00:00
|
|
|
CHANNEL_MESSAGE = 3,
|
2020-12-16 10:42:52 +00:00
|
|
|
/** Send a channel message with "<User> used /<Command> with <Bot>" */
|
2020-12-10 04:36:36 +00:00
|
|
|
CHANNEL_MESSAGE_WITH_SOURCE = 4,
|
2020-12-16 10:42:52 +00:00
|
|
|
/** Send nothing further, but send "<User> used /<Command> with <Bot>" */
|
2020-12-10 04:36:36 +00:00
|
|
|
ACK_WITH_SOURCE = 5
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface InteractionResponsePayload {
|
|
|
|
type: InteractionResponseType
|
|
|
|
data?: InteractionResponseDataPayload
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface InteractionResponseDataPayload {
|
|
|
|
tts?: boolean
|
|
|
|
content: string
|
|
|
|
embeds?: EmbedPayload[]
|
|
|
|
allowed_mentions?: {
|
|
|
|
parse?: 'everyone' | 'users' | 'roles'
|
|
|
|
roles?: string[]
|
|
|
|
users?: string[]
|
|
|
|
}
|
|
|
|
flags?: number
|
|
|
|
}
|
2020-12-16 10:42:52 +00:00
|
|
|
|
|
|
|
export enum InteractionResponseFlags {
|
|
|
|
/** A Message which is only visible to Interaction User, and is not saved on backend */
|
|
|
|
EPHEMERAL = 1 << 6
|
|
|
|
}
|