From a6c5dab29e09717efe665f955ed7ca6de9ebcdfe Mon Sep 17 00:00:00 2001 From: ITOH Date: Tue, 8 Jun 2021 18:51:26 +0200 Subject: [PATCH] test this --- src/types/interactions/interaction.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/types/interactions/interaction.ts b/src/types/interactions/interaction.ts index 57d4b32c1..401916e2d 100644 --- a/src/types/interactions/interaction.ts +++ b/src/types/interactions/interaction.ts @@ -8,23 +8,27 @@ import { ButtonData } from "../messages/components/button_data.ts"; /** https://discord.com/developers/docs/interactions/slash-commands#interaction */ export type Interaction = SlashCommandInteraction | ComponentInteraction; -export interface SlashCommandInteraction extends BaseInteraction { - type: DiscordInteractionTypes.ApplicationCommand; - data?: ApplicationCommandInteractionData; -} -export interface ComponentInteraction extends BaseInteraction { - type: DiscordInteractionTypes.MessageComponent; - data?: ButtonData | SelectMenuData; -} +export type SlashCommandInteraction = BaseInteraction< + DiscordInteractionTypes.ApplicationCommand, + ApplicationCommandInteractionData +>; -export interface BaseInteraction { +export type ComponentInteraction = BaseInteraction< + DiscordInteractionTypes.MessageComponent, + ButtonData | SelectMenuData +>; + +export interface BaseInteraction< + T extends DiscordInteractionTypes, + D extends ApplicationCommandInteractionData | ButtonData | SelectMenuData +> { /** Id of the interaction */ id: string; /** Id of the application this interaction is for */ applicationId: string; /** The type of interaction */ - type: DiscordInteractionTypes; + type: T; /** The guild it was sent from */ guildId?: string; /** The channel it was sent from */ @@ -39,4 +43,6 @@ export interface BaseInteraction { version: 1; /** For the message the button was attached to */ message?: Message; + + data?: D; }