@@ -13,21 +13,41 @@ import {
1313 PermissionString ,
1414 SelectMenuInteraction ,
1515 MessageSelectOptionData ,
16- ButtonInteraction
16+ ButtonInteraction ,
17+ MessageSelectMenu ,
18+ MessageButton ,
19+ MessageButtonStyleResolvable ,
20+ EmojiResolvable
1721} from "discord.js" ;
1822
23+ interface CustomSelectMenuOptions {
24+ min ?: number ;
25+ max ?: number ;
26+ choices : MessageSelectOptionData [ ] ;
27+ placeholder ?: string ;
28+ onComplete ?( interaction : SelectMenuInteraction ) : MessageSelectOptionData [ ]
29+ }
30+
31+ interface CustomButtonOptions {
32+ emoji ?: EmojiResolvable ;
33+ label ?: string ;
34+ style : MessageButtonStyleResolvable ;
35+ url ?: string ;
36+ }
37+
1938export type CustomApplicationCommandOptionData = (
2039 ApplicationCommandNonOptionsData
2140 | ApplicationCommandChannelOptionData
2241 | ApplicationCommandChoicesData
23- ) & { onComplete ( interaction : AutocompleteInteraction , value : string | number ) : Promise < ApplicationCommandOptionChoice [ ] > }
42+ ) & { onComplete ( interaction : AutocompleteInteraction , value : string | number ) : ApplicationCommandOptionChoice [ ] }
2443
2544export class BaseInteraction {
2645 private _type : string ;
2746 name : string [ ] ;
2847 id ?: string ;
2948 perms ?: { bot : PermissionString [ ] , user : PermissionString [ ] } ;
30- onInteraction : ( interaction : CommandInteraction | ContextMenuInteraction , other : IOther ) => void ;
49+ onInteraction ( interaction : CommandInteraction | ContextMenuInteraction , other : IOther ) : void ;
50+ toJSON ( ) : MessageButton | MessageSelectMenu | undefined ;
3151 onLoad ?( client : Client ) : void ;
3252 coolDowns : Map < string , number > ;
3353 description ! : string ;
@@ -38,12 +58,17 @@ export class BaseInteraction {
3858 guildOnly ?: boolean ;
3959 options ?: CustomApplicationCommandOptionData [ ] ;
4060 defaultPermission ?: boolean ;
41- actionType ?: ApplicationCommandType ;
42- constructor ( arg : TInteractionConstructor )
61+ actionType ?: ApplicationCommandType | "SELECT_MENU" | "BUTTON" ;
62+ isSelectMenu ( ) : this is import ( "./SelectMenu" ) ;
63+ isButton ( ) : this is import ( "./Button" ) ;
64+ isChatActionCommand ( ) : this is import ( "./SlashCommand" ) ;
65+ isUserActionCommand ( ) : this is import ( "./UserAction" ) ;
66+ isMessageActionCommand ( ) : this is import ( "./MessageAction" ) ;
67+ constructor ( arg : TInteractionConstructor ) ;
4368}
4469
45- export type TOmittedInteraction = Omit < BaseInteraction , "_type" | "coolDowns" | "name" | "onInteraction" | "actionType" | "options" > ;
46- export type TInteractionConstructor = TOmittedInteraction & ( ( ActionChatCommand | ActionRightClickCommand ) & SelectMenu ) ;
70+ export type TOmittedInteraction = Omit < BaseInteraction , "_type" | "coolDowns" | "name" | "onInteraction" | "actionType" | "options" | "toJSON" > ;
71+ export type TInteractionConstructor = TOmittedInteraction & ( ( ActionChatCommand | ActionRightClickCommand | SelectMenu | Button ) ) ;
4772
4873export interface IOther {
4974 setCoolDown ( durations : number ) : void ,
@@ -53,29 +78,33 @@ export interface IOther {
5378export interface ActionChatCommand {
5479 name : string [ ] ;
5580 actionType : "CHAT_INPUT" ;
56- onInteraction : ( interaction : CommandInteraction , other : IOther ) => void ;
81+ onInteraction ( interaction : CommandInteraction , other : IOther ) : void ;
5782 options : CustomApplicationCommandOptionData [ ] ;
83+ toJSON ( ) : undefined ;
5884}
5985
6086export interface ActionRightClickCommand {
6187 name : string ;
6288 actionType : "MESSAGE" | "USER" ;
63- onInteraction : ( interaction : ContextMenuInteraction , other : IOther ) => void ;
89+ onInteraction ( interaction : ContextMenuInteraction , other : IOther ) : void ;
6490 options : undefined ;
91+ toJSON ( ) : undefined ;
6592}
6693
6794export interface SelectMenu {
6895 name : string ;
6996 actionType : "SELECT_MENU" ;
70- onInteraction : ( interaction : SelectMenuInteraction , other : IOther ) => void ;
71- options ?: MessageSelectOptionData [ ]
97+ onInteraction ( interaction : SelectMenuInteraction , other : IOther ) : void ;
98+ options ?: CustomSelectMenuOptions ;
99+ toJSON ( ) : MessageSelectMenu ;
72100}
73101
74102export interface Button {
75103 name : string ;
76104 actionType : "BUTTON" ;
77- onInteraction : ( interaction : ButtonInteraction , other : IOther ) => void ;
78- options ?: undefined ;
105+ onInteraction ( interaction : ButtonInteraction , other : IOther ) : void ;
106+ options ?: CustomButtonOptions ;
107+ toJSON ( ) : MessageButton ;
79108}
80109
81110export = BaseInteraction ;
0 commit comments