mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 17:00:08 +00:00
types: add interactions types (#709)
* types: add Interaction ApplicationCommand type * types: add Interaction ApplicationCommandInteractionData type * types: add Interaction ApplicationCommandInteractionData type * types: add Interaction ApplicationCommandInteractionDataOption * types: add Interaction ApplicationCommandOption * types: add Interaction ApplicatoinCommandOptionChoice * types: add Interaction ApplicationCommandOptionTypes * types: add Interaction CreateGlobalApplicationCommand * types: add Interaction CreateGuildApplicationCommand * types: add Interaction EditGlobalApplicationCommand * types: add Interaction EditGuildApplicationCommand * types: add Interaction * types: add Interaction InteractionResponse * types: add Interaction InteractionResponseTypes * types: add Interaction InteractionTypes * types: add Interaction MessageInteraction * change names * my bad * Update src/types/interactions/application_command_callback_data.ts * Update src/types/interactions/interaction.ts * InteractionTypes => DiscordInteractionTypes * s * delete this test file Co-authored-by: ayntee <ayyantee@gmail.com>
This commit is contained in:
18
src/types/interactions/application_command.ts
Normal file
18
src/types/interactions/application_command.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
import { ApplicationCommandOption } from "./application_command_option.ts";
|
||||
|
||||
export interface ApplicationCommand {
|
||||
/** Unique id of the command */
|
||||
id: string;
|
||||
/** Unique id of the parent application */
|
||||
applicationId: string;
|
||||
/** 1-32 character name matching `^[\w-]{1,32}$` */
|
||||
name: string;
|
||||
/** 1-100 character description */
|
||||
description: string;
|
||||
/** The parameters for the command */
|
||||
options?: ApplicationCommandOption[];
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommand */
|
||||
export type DiscordApplicationCommand = SnakeCaseProps<ApplicationCommand>;
|
||||
21
src/types/interactions/application_command_callback_data.ts
Normal file
21
src/types/interactions/application_command_callback_data.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Embed } from "../embeds/embed.ts";
|
||||
import { AllowedMentions } from "../messages/allowed_mentions.ts";
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
|
||||
export interface InteractionApplicationCommandCallbackData {
|
||||
/** Is the response TTS */
|
||||
tts?: boolean;
|
||||
/** Message content */
|
||||
content?: string;
|
||||
/** Supports up to 10 embeds */
|
||||
embeds?: Embed[];
|
||||
/** Allowed Mentions object */
|
||||
allowedMentions?: AllowedMentions;
|
||||
/** Set to `64` to make your response ephemeral */
|
||||
flags?: number;
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata */
|
||||
export type DiscordInteractionApplicationCommandCallbackData = SnakeCaseProps<
|
||||
InteractionApplicationCommandCallbackData
|
||||
>;
|
||||
@@ -0,0 +1,16 @@
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
import { ApplicationCommandInteractionDataOption } from "./application_command_interaction_data_option.ts";
|
||||
|
||||
export interface ApplicationCommandInteractionData {
|
||||
/** The ID of the invoked command */
|
||||
id: string;
|
||||
/** The name of the invoked command */
|
||||
name: string;
|
||||
/** The params + values from the user */
|
||||
options?: ApplicationCommandInteractionDataOption[];
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata */
|
||||
export type DiscordApplicationCommandInteractionData = SnakeCaseProps<
|
||||
ApplicationCommandInteractionData
|
||||
>;
|
||||
@@ -0,0 +1,16 @@
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
import { DiscordApplicationCommandOptionTypes } from "./application_command_option_types.ts";
|
||||
|
||||
export interface ApplicationCommandInteractionDataOption {
|
||||
/** The name of the parameter */
|
||||
name: string;
|
||||
/** The value of the pair */
|
||||
value?: DiscordApplicationCommandOptionTypes;
|
||||
/** Present if this option is a group or subcommand */
|
||||
options?: ApplicationCommandInteractionDataOption[];
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption */
|
||||
export type DiscordApplicationCommandInteractionDataOption = SnakeCaseProps<
|
||||
ApplicationCommandInteractionDataOption
|
||||
>;
|
||||
23
src/types/interactions/application_command_option.ts
Normal file
23
src/types/interactions/application_command_option.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
import { ApplicationCommandOptionChoice } from "./application_command_option_choice.ts";
|
||||
import { DiscordApplicationCommandOptionTypes } from "./application_command_option_types.ts";
|
||||
|
||||
export interface ApplicationCommandOption {
|
||||
/** Value of Application Command Option Type */
|
||||
type: DiscordApplicationCommandOptionTypes;
|
||||
/** 1-32 character name matching `^[\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?: ApplicationCommandOptionChoice[];
|
||||
/** If the optino is a subcommand or subcommand group type, this nested options will be the parameters */
|
||||
options?: ApplicationCommandOption[];
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption */
|
||||
export type DiscordApplicationCommandOption = SnakeCaseProps<
|
||||
ApplicationCommandOption
|
||||
>;
|
||||
10
src/types/interactions/application_command_option_choice.ts
Normal file
10
src/types/interactions/application_command_option_choice.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export interface ApplicationCommandOptionChoice {
|
||||
/** 1-100 character choice name */
|
||||
name: string;
|
||||
/** Value of the choice, up to 100 characters if string */
|
||||
value: string | number;
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice */
|
||||
export type DiscordApplicationCommandOptionChoice =
|
||||
ApplicationCommandOptionChoice;
|
||||
11
src/types/interactions/application_command_option_types.ts
Normal file
11
src/types/interactions/application_command_option_types.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype */
|
||||
export enum DiscordApplicationCommandOptionTypes {
|
||||
SUB_COMMAND = 1,
|
||||
SUB_COMMAND_GROUP,
|
||||
STRING,
|
||||
INTEGER,
|
||||
BOOLEAN,
|
||||
USER,
|
||||
CHANNEL,
|
||||
ROLE,
|
||||
}
|
||||
16
src/types/interactions/create_global_application_command.ts
Normal file
16
src/types/interactions/create_global_application_command.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
import { ApplicationCommandOption } from "./application_command_option.ts";
|
||||
|
||||
export interface CreateGlobalApplicationCommand {
|
||||
/** 1-31 character name matching `^[\w-]{1,32}$` */
|
||||
name: string;
|
||||
/** 1-100 character description */
|
||||
description: string;
|
||||
/** The parameters for the command */
|
||||
options?: ApplicationCommandOption[];
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command-json-params */
|
||||
export type DiscordCreateGlobalApplicationCommand = SnakeCaseProps<
|
||||
CreateGlobalApplicationCommand
|
||||
>;
|
||||
16
src/types/interactions/create_guild_application_command.ts
Normal file
16
src/types/interactions/create_guild_application_command.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
import { ApplicationCommandOption } from "./application_command_option.ts";
|
||||
|
||||
export interface CreateGuildApplicationCommand {
|
||||
/** 1-31 character name matching `^[\w-]{1,32}$` */
|
||||
name: string;
|
||||
/** 1-100 character description */
|
||||
description: string;
|
||||
/** The parameters for the command */
|
||||
options?: ApplicationCommandOption[];
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command-json-params */
|
||||
export type DiscordCreateGuildApplicationCommand = SnakeCaseProps<
|
||||
CreateGuildApplicationCommand
|
||||
>;
|
||||
16
src/types/interactions/edit_global_application_command.ts
Normal file
16
src/types/interactions/edit_global_application_command.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
import { ApplicationCommandOption } from "./application_command_option.ts";
|
||||
|
||||
export interface EditGlobalApplicationCommand {
|
||||
/** 1-31 character name matching `^[\w-]{1,32}$` */
|
||||
name?: string;
|
||||
/** 1-100 character description */
|
||||
description?: string;
|
||||
/** The parameters for the command */
|
||||
options?: ApplicationCommandOption[] | null;
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command-json-params */
|
||||
export type DiscordEditGlobalApplicationCommand = SnakeCaseProps<
|
||||
EditGlobalApplicationCommand
|
||||
>;
|
||||
16
src/types/interactions/edit_guild_application_command.ts
Normal file
16
src/types/interactions/edit_guild_application_command.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
import { ApplicationCommandOption } from "./application_command_option.ts";
|
||||
|
||||
export interface EditGuildApplicationCommand {
|
||||
/** 1-31 character name matching `^[\w-]{1,32}$` */
|
||||
name?: string;
|
||||
/** 1-100 character description */
|
||||
description?: string;
|
||||
/** The parameters for the command */
|
||||
options?: ApplicationCommandOption[] | null;
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command-json-params */
|
||||
export type DiscordEditGuildApplicationCommand = SnakeCaseProps<
|
||||
EditGuildApplicationCommand
|
||||
>;
|
||||
28
src/types/interactions/interaction.ts
Normal file
28
src/types/interactions/interaction.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { User } from "../users/user.ts";
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
import { InteractionApplicationCommandCallbackData } from "./application_command_callback_data.ts";
|
||||
import { DiscordInteractionTypes } from "./interaction_types.ts";
|
||||
|
||||
export interface Interaction {
|
||||
/** id of the interaction */
|
||||
id: string;
|
||||
/** The type of interaction */
|
||||
type: DiscordInteractionTypes;
|
||||
/** The command data payload */
|
||||
data?: InteractionApplicationCommandCallbackData;
|
||||
/** The guild it was sent from */
|
||||
guildId?: string;
|
||||
/** The channel it was sent from */
|
||||
channelId?: string;
|
||||
/** Guild member data for the invoking user, including permissions */
|
||||
member?: GuildMember;
|
||||
/** User object for the invoking user, if invoked in a DM */
|
||||
user?: User;
|
||||
/** A continuation token for responding to the interaction */
|
||||
token: string;
|
||||
/** Read-only property, always `1` */
|
||||
version: 1;
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#interaction */
|
||||
export type DiscordInteraction = SnakeCaseProps<Interaction>;
|
||||
13
src/types/interactions/interaction_response.ts
Normal file
13
src/types/interactions/interaction_response.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
import { InteractionApplicationCommandCallbackData } from "./application_command_callback_data.ts";
|
||||
import { InteractionResponseTypes } from "./interaction_response_types.ts";
|
||||
|
||||
export interface InteractionResponse {
|
||||
/** The type of response */
|
||||
type: InteractionResponseTypes;
|
||||
/** An optional response message */
|
||||
data?: InteractionApplicationCommandCallbackData;
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response */
|
||||
export type DiscordInteractionResponse = SnakeCaseProps<InteractionResponse>;
|
||||
9
src/types/interactions/interaction_response_types.ts
Normal file
9
src/types/interactions/interaction_response_types.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionresponsetype */
|
||||
export enum InteractionResponseTypes {
|
||||
/** ACK a `Ping` */
|
||||
Pong = 1,
|
||||
/** Respond to an interaction with a message */
|
||||
ChannelMessageWithSource = 4,
|
||||
/** ACK an interaction and edit to a response later, the user sees a loading state */
|
||||
DeferredChannelMessageWithSource = 5,
|
||||
}
|
||||
5
src/types/interactions/interaction_types.ts
Normal file
5
src/types/interactions/interaction_types.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype */
|
||||
export enum DiscordInteractionTypes {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
}
|
||||
17
src/types/interactions/message_interaction.ts
Normal file
17
src/types/interactions/message_interaction.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { User } from "../users/user.ts";
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
import { DiscordInteractionTypes } from "./interaction_types.ts";
|
||||
|
||||
export interface MessageInteraction {
|
||||
/** Id of the interaction */
|
||||
id: string;
|
||||
/** The type of interaction */
|
||||
type: DiscordInteractionTypes;
|
||||
/** The name of the ApplicationCommand */
|
||||
name: string;
|
||||
/** The user who invoked the interaction */
|
||||
user: User;
|
||||
}
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#messageinteraction */
|
||||
export type DiscordMessageInteraction = SnakeCaseProps<MessageInteraction>;
|
||||
Reference in New Issue
Block a user