Skip to content

Commit b4b70d8

Browse files
authored
feat: entry point commands and interaction callback response (#1077)
1 parent 3de4ca8 commit b4b70d8

File tree

13 files changed

+567
-0
lines changed

13 files changed

+567
-0
lines changed

.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
"RESTAPIGuildCreateRole",
3636
"RESTAPIGuildOnboardingPrompt",
3737
"RESTAPIGuildOnboardingPromptOption",
38+
"RESTAPIInteractionCallbackActivityInstanceResource",
39+
"RESTAPIInteractionCallbackObject",
40+
"RESTAPIInteractionCallbackResourceObject",
3841
"RESTAPIMessageReference",
3942
"RESTAPIPartialCurrentUserGuild",
4043
"RESTAPIPoll",

deno/payloads/v10/_interactions/applicationCommands.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,35 @@ export interface APIApplicationCommand {
102102
* Autoincrementing version identifier updated during substantial record changes
103103
*/
104104
version: Snowflake;
105+
/**
106+
* Determines whether the interaction is handled by the app's interactions handler or by Discord
107+
*
108+
* @remarks
109+
* This is only available for {@link ApplicationCommandType.PrimaryEntryPoint} commands
110+
*/
111+
handler?: EntryPointCommandHandlerType;
105112
}
106113

107114
/**
108115
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types
109116
*/
110117
export enum ApplicationCommandType {
118+
/**
119+
* Slash commands; a text-based command that shows up when a user types `/`
120+
*/
111121
ChatInput = 1,
122+
/**
123+
* A UI-based command that shows up when you right click or tap on a user
124+
*/
112125
User,
126+
/**
127+
* A UI-based command that shows up when you right click or tap on a message
128+
*/
113129
Message,
130+
/**
131+
* A UI-based command that represents the primary way to invoke an app's Activity
132+
*/
133+
PrimaryEntryPoint,
114134
}
115135

116136
/**
@@ -145,6 +165,21 @@ export enum InteractionContextType {
145165
PrivateChannel,
146166
}
147167

168+
/**
169+
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-entry-point-command-handler-types
170+
*/
171+
export enum EntryPointCommandHandlerType {
172+
/**
173+
* The app handles the interaction using an interaction token
174+
*/
175+
AppHandler = 1,
176+
/**
177+
* Discord handles the interaction by launching an Activity and sending a follow-up message without coordinating with
178+
* the app
179+
*/
180+
DiscordLaunchActivity,
181+
}
182+
148183
/**
149184
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data
150185
*/

deno/payloads/v10/_interactions/responses.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ export enum InteractionResponseType {
102102
* @deprecated See https://discord.com/developers/docs/change-log#premium-apps-new-premium-button-style-deep-linking-url-schemes
103103
*/
104104
PremiumRequired,
105+
106+
/**
107+
* Launch the Activity associated with the app.
108+
*
109+
* @remarks
110+
* Only available for apps with Activities enabled
111+
*/
112+
LaunchActivity = 12,
105113
}
106114

107115
/**

deno/payloads/v9/_interactions/applicationCommands.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,35 @@ export interface APIApplicationCommand {
102102
* Autoincrementing version identifier updated during substantial record changes
103103
*/
104104
version: Snowflake;
105+
/**
106+
* Determines whether the interaction is handled by the app's interactions handler or by Discord
107+
*
108+
* @remarks
109+
* This is only available for {@link ApplicationCommandType.PrimaryEntryPoint} commands
110+
*/
111+
handler?: EntryPointCommandHandlerType;
105112
}
106113

107114
/**
108115
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types
109116
*/
110117
export enum ApplicationCommandType {
118+
/**
119+
* Slash commands; a text-based command that shows up when a user types `/`
120+
*/
111121
ChatInput = 1,
122+
/**
123+
* A UI-based command that shows up when you right click or tap on a user
124+
*/
112125
User,
126+
/**
127+
* A UI-based command that shows up when you right click or tap on a message
128+
*/
113129
Message,
130+
/**
131+
* A UI-based command that represents the primary way to invoke an app's Activity
132+
*/
133+
PrimaryEntryPoint,
114134
}
115135

116136
/**
@@ -145,6 +165,21 @@ export enum InteractionContextType {
145165
PrivateChannel,
146166
}
147167

168+
/**
169+
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-entry-point-command-handler-types
170+
*/
171+
export enum EntryPointCommandHandlerType {
172+
/**
173+
* The app handles the interaction using an interaction token
174+
*/
175+
AppHandler = 1,
176+
/**
177+
* Discord handles the interaction by launching an Activity and sending a follow-up message without coordinating with
178+
* the app
179+
*/
180+
DiscordLaunchActivity,
181+
}
182+
148183
/**
149184
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data
150185
*/

deno/payloads/v9/_interactions/responses.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ export enum InteractionResponseType {
102102
* @deprecated See https://discord.com/developers/docs/change-log#premium-apps-new-premium-button-style-deep-linking-url-schemes
103103
*/
104104
PremiumRequired,
105+
106+
/**
107+
* Launch the Activity associated with the app.
108+
*
109+
* @remarks
110+
* Only available for apps with Activities enabled
111+
*/
112+
LaunchActivity = 12,
105113
}
106114

107115
/**

deno/rest/v10/interactions.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import type { Snowflake } from '../../globals.ts';
12
import type {
23
APIApplicationCommand,
34
APIApplicationCommandPermission,
45
APIGuildApplicationCommandPermissions,
56
APIInteractionResponse,
67
APIInteractionResponseCallbackData,
78
ApplicationCommandType,
9+
InteractionResponseType,
10+
APIMessage,
11+
InteractionType,
812
} from '../../payloads/v10/mod.ts';
913
import type {
1014
AddUndefinedToPossiblyUndefinedPropertiesOfInterface,
@@ -171,6 +175,16 @@ export type RESTPutAPIApplicationGuildCommandsResult = Omit<APIApplicationComman
171175
*/
172176
export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse;
173177

178+
/**
179+
* https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
180+
*/
181+
export interface RESTPostAPIInteractionCallbackQuery {
182+
/**
183+
* Whether to include a interaction callback response as the response instead of a 204
184+
*/
185+
with_response?: boolean;
186+
}
187+
174188
/**
175189
* https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
176190
*/
@@ -183,6 +197,90 @@ export type RESTPostAPIInteractionCallbackFormDataBody =
183197
})
184198
| (Record<`files[${bigint}]`, unknown> & RESTPostAPIInteractionCallbackJSONBody);
185199

200+
/**
201+
* https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
202+
*/
203+
export type RESTPostAPIInteractionCallbackResult = never;
204+
205+
/**
206+
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-callback-interaction-callback-response-object
207+
*/
208+
export interface RESTPostAPIInteractionCallbackWithResponseResult {
209+
/**
210+
* The interaction object associated with the interaction
211+
*/
212+
interaction: RESTAPIInteractionCallbackObject;
213+
/**
214+
* The resource that was created by the interaction response
215+
*/
216+
resource?: RESTAPIInteractionCallbackResourceObject;
217+
}
218+
219+
/**
220+
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-callback-interaction-callback-object
221+
*/
222+
export interface RESTAPIInteractionCallbackObject {
223+
/**
224+
* ID of the interaction
225+
*/
226+
id: Snowflake;
227+
/**
228+
* Interaction type
229+
*/
230+
type: InteractionType;
231+
/**
232+
* Instance ID of the Activity if one was launched or joined
233+
*/
234+
activity_instance_id?: string;
235+
/**
236+
* ID of the message that was created by the interaction
237+
*/
238+
response_message_id?: Snowflake;
239+
/**
240+
* Whether or not the message is in a loading state
241+
*/
242+
response_message_loading?: boolean;
243+
/**
244+
* Whether or not the response message was ephemeral
245+
*/
246+
response_message_ephemeral?: boolean;
247+
}
248+
249+
/**
250+
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-callback-interaction-callback-resource-object
251+
*/
252+
export interface RESTAPIInteractionCallbackResourceObject {
253+
/**
254+
* Interaction callback type
255+
*/
256+
type: InteractionResponseType;
257+
/**
258+
* Represents the Activity launched by this interaction
259+
*
260+
* @remarks
261+
* Only present if `type` is {@link InteractionResponseType.LaunchActivity}
262+
*/
263+
activity_instance?: RESTAPIInteractionCallbackActivityInstanceResource;
264+
/**
265+
* Message created by the interaction
266+
*
267+
* @remarks
268+
* Only present if `type` is {@link InteractionResponseType.ChannelMessageWithSource}
269+
* or {@link InteractionResponseType.UpdateMessage}
270+
*/
271+
message?: APIMessage;
272+
}
273+
274+
/**
275+
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-callback-interaction-callback-activity-instance-resource
276+
*/
277+
export interface RESTAPIInteractionCallbackActivityInstanceResource {
278+
/**
279+
* Instance ID of the Activity if one was launched or joined.
280+
*/
281+
id: string;
282+
}
283+
186284
/**
187285
* https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response
188286
*/

0 commit comments

Comments
 (0)