Skip to content

Commit c457b8d

Browse files
feat: user-installable apps (#921)
Co-authored-by: Vlad Frangu <[email protected]>
1 parent 7650ce4 commit c457b8d

26 files changed

+524
-20
lines changed

deno/payloads/v10/_interactions/applicationCommands.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ export interface APIApplicationCommand {
7474
default_member_permissions: Permissions | null;
7575
/**
7676
* Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible
77+
*
78+
* @deprecated Use `contexts` instead
7779
*/
7880
dm_permission?: boolean;
7981
/**
@@ -88,6 +90,18 @@ export interface APIApplicationCommand {
8890
* Indicates whether the command is age-restricted, defaults to `false`
8991
*/
9092
nsfw?: boolean;
93+
/**
94+
* Installation context(s) where the command is available, only for globally-scoped commands. Defaults to `GUILD_INSTALL ([0])`
95+
*
96+
* @unstable
97+
*/
98+
integration_types?: ApplicationIntegrationType[];
99+
/**
100+
* Interaction context(s) where the command can be used, only for globally-scoped commands. By default, all interaction context types included for new commands `[0,1,2]`.
101+
*
102+
* @unstable
103+
*/
104+
contexts?: InteractionContextType[] | null;
91105
/**
92106
* Autoincrementing version identifier updated during substantial record changes
93107
*/
@@ -103,6 +117,38 @@ export enum ApplicationCommandType {
103117
Message,
104118
}
105119

120+
/**
121+
* https://discord.com/developers/docs/resources/application#application-object-application-integration-types
122+
*/
123+
export enum ApplicationIntegrationType {
124+
/**
125+
* App is installable to servers
126+
*/
127+
GuildInstall = 0,
128+
/**
129+
* App is installable to users
130+
*/
131+
UserInstall = 1,
132+
}
133+
134+
/**
135+
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-context-types
136+
*/
137+
export enum InteractionContextType {
138+
/**
139+
* Interaction can be used within servers
140+
*/
141+
Guild = 0,
142+
/**
143+
* Interaction can be used within DMs with the app's bot user
144+
*/
145+
BotDM = 1,
146+
/**
147+
* Interaction can be used within Group DMs and DMs other than the app's bot user
148+
*/
149+
PrivateChannel = 2,
150+
}
151+
106152
/**
107153
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data
108154
*/

deno/payloads/v10/_interactions/base.ts

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Permissions, Snowflake } from '../../../globals.ts';
2-
import type { APIRole, LocaleString } from '../../../v10.ts';
2+
import type { APIRole, ApplicationIntegrationType, InteractionContextType, LocaleString } from '../../../v10.ts';
33
import type {
44
APIAttachment,
55
APIChannel,
@@ -14,6 +14,40 @@ import type { APIEntitlement } from '../monetization.ts';
1414
import type { APIUser } from '../user.ts';
1515
import type { InteractionType } from './responses.ts';
1616

17+
/**
18+
* https://discord.com/developers/docs/resources/channel#message-interaction-metadata-object
19+
*/
20+
export interface APIMessageInteractionMetadata {
21+
/**
22+
* ID of the interaction
23+
*/
24+
id: Snowflake;
25+
/**
26+
* Type of interaction
27+
*/
28+
type: InteractionType;
29+
/**
30+
* User who triggered the interaction
31+
*/
32+
user: APIUser;
33+
/**
34+
* IDs for installation context(s) related to an interaction. Details in Authorizing Integration Owners Object
35+
*/
36+
authorizing_integration_owners: APIAuthorizingIntegrationOwnersMap;
37+
/**
38+
* ID of the original response message, present only on follow-up messages
39+
*/
40+
original_response_message_id?: Snowflake;
41+
/**
42+
* ID of the message that contained interactive component, present only on messages created from component interactions
43+
*/
44+
interacted_message_id?: Snowflake;
45+
/**
46+
* Metadata for the interaction that was used to open the modal, present only on modal submit interactions
47+
*/
48+
triggering_interaction_metadata?: APIMessageInteractionMetadata;
49+
}
50+
1751
export type PartialAPIMessageInteractionGuildMember = Pick<
1852
APIGuildMember,
1953
| 'avatar'
@@ -122,7 +156,7 @@ export interface APIBaseInteraction<Type extends InteractionType, Data> {
122156
/**
123157
* Bitwise set of permissions the app or bot has within the channel the interaction was sent from
124158
*/
125-
app_permissions?: Permissions;
159+
app_permissions: Permissions;
126160
/**
127161
* The selected language of the invoking user
128162
*/
@@ -135,8 +169,20 @@ export interface APIBaseInteraction<Type extends InteractionType, Data> {
135169
* For monetized apps, any entitlements for the invoking user, representing access to premium SKUs
136170
*/
137171
entitlements: APIEntitlement[];
172+
/**
173+
* Mapping of installation contexts that the interaction was authorized for to related user or guild IDs.
174+
*/
175+
authorizing_integration_owners: APIAuthorizingIntegrationOwnersMap;
176+
/**
177+
* Context where the interaction was triggered from
178+
*/
179+
context?: InteractionContextType;
138180
}
139181

182+
export type APIAuthorizingIntegrationOwnersMap = {
183+
[key in ApplicationIntegrationType]?: Snowflake;
184+
};
185+
140186
export type APIDMInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
141187
Original,
142188
'guild_id' | 'member'

deno/payloads/v10/application.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import type { Permissions, Snowflake } from '../../globals.ts';
66
import type { LocalizationMap } from '../common.ts';
77
import type { APIPartialGuild } from './guild.ts';
8+
import type { ApplicationIntegrationType } from './interactions.ts';
89
import type { OAuth2Scopes } from './oauth2.ts';
910
import type { APITeam } from './teams.ts';
1011
import type { APIUser } from './user.ts';
@@ -128,6 +129,12 @@ export interface APIApplication {
128129
* Settings for the application's default in-app authorization link, if enabled
129130
*/
130131
install_params?: APIApplicationInstallParams;
132+
/**
133+
* Default scopes and permissions for each supported installation context. Value for each key is an integration type configuration object
134+
*
135+
* @unstable
136+
*/
137+
integration_types_config?: APIApplicationIntegrationTypesConfigMap;
131138
/**
132139
* The application's default custom authorization link, if enabled
133140
*/
@@ -139,6 +146,14 @@ export interface APIApplicationInstallParams {
139146
permissions: Permissions;
140147
}
141148

149+
export interface APIApplicationIntegrationTypeConfiguration {
150+
oauth2_install_params?: APIApplicationInstallParams;
151+
}
152+
153+
export type APIApplicationIntegrationTypesConfigMap = {
154+
[key in ApplicationIntegrationType]?: APIApplicationIntegrationTypeConfiguration;
155+
};
156+
142157
/**
143158
* https://discord.com/developers/docs/resources/application#application-object-application-flags
144159
*/

deno/payloads/v10/channel.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { Permissions, Snowflake } from '../../globals.ts';
66
import type { APIApplication } from './application.ts';
77
import type { APIPartialEmoji } from './emoji.ts';
88
import type { APIGuildMember } from './guild.ts';
9-
import type { APIInteractionDataResolved, APIMessageInteraction } from './interactions.ts';
9+
import type { APIInteractionDataResolved, APIMessageInteraction, APIMessageInteractionMetadata } from './interactions.ts';
1010
import type { APIRole } from './permissions.ts';
1111
import type { APIPoll } from './poll.ts';
1212
import type { APISticker, APIStickerItem } from './sticker.ts';
@@ -667,8 +667,16 @@ export interface APIMessage {
667667
* See https://discord.com/developers/docs/resources/channel#message-object
668668
*/
669669
referenced_message?: APIMessage | null;
670+
/**
671+
* Sent if the message is sent as a result of an interaction
672+
*
673+
* @unstable
674+
*/
675+
interaction_metadata?: APIMessageInteractionMetadata;
670676
/**
671677
* Sent if the message is a response to an Interaction
678+
*
679+
* @deprecated In favor of `interaction_metadata`
672680
*/
673681
interaction?: APIMessageInteraction;
674682
/**

deno/payloads/v9/_interactions/applicationCommands.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ export interface APIApplicationCommand {
7474
default_member_permissions: Permissions | null;
7575
/**
7676
* Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible
77+
*
78+
* @deprecated Use `contexts` instead
7779
*/
7880
dm_permission?: boolean;
7981
/**
@@ -88,6 +90,18 @@ export interface APIApplicationCommand {
8890
* Indicates whether the command is age-restricted, defaults to `false`
8991
*/
9092
nsfw?: boolean;
93+
/**
94+
* Installation context(s) where the command is available, only for globally-scoped commands. Defaults to `GUILD_INSTALL ([0])`
95+
*
96+
* @unstable
97+
*/
98+
integration_types?: ApplicationIntegrationType[];
99+
/**
100+
* Interaction context(s) where the command can be used, only for globally-scoped commands. By default, all interaction context types included for new commands `[0,1,2]`.
101+
*
102+
* @unstable
103+
*/
104+
contexts?: InteractionContextType[] | null;
91105
/**
92106
* Autoincrementing version identifier updated during substantial record changes
93107
*/
@@ -103,6 +117,38 @@ export enum ApplicationCommandType {
103117
Message,
104118
}
105119

120+
/**
121+
* https://discord.com/developers/docs/resources/application#application-object-application-integration-types
122+
*/
123+
export enum ApplicationIntegrationType {
124+
/**
125+
* App is installable to servers
126+
*/
127+
GuildInstall = 0,
128+
/**
129+
* App is installable to users
130+
*/
131+
UserInstall = 1,
132+
}
133+
134+
/**
135+
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-context-types
136+
*/
137+
export enum InteractionContextType {
138+
/**
139+
* Interaction can be used within servers
140+
*/
141+
Guild = 0,
142+
/**
143+
* Interaction can be used within DMs with the app's bot user
144+
*/
145+
BotDM = 1,
146+
/**
147+
* Interaction can be used within Group DMs and DMs other than the app's bot user
148+
*/
149+
PrivateChannel = 2,
150+
}
151+
106152
/**
107153
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data
108154
*/

deno/payloads/v9/_interactions/base.ts

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Permissions, Snowflake } from '../../../globals.ts';
2-
import type { APIRole, LocaleString } from '../../../v9.ts';
2+
import type { APIRole, ApplicationIntegrationType, InteractionContextType, LocaleString } from '../../../v9.ts';
33
import type {
44
APIAttachment,
55
APIChannel,
@@ -14,6 +14,40 @@ import type { APIEntitlement } from '../monetization.ts';
1414
import type { APIUser } from '../user.ts';
1515
import type { InteractionType } from './responses.ts';
1616

17+
/**
18+
* https://discord.com/developers/docs/resources/channel#message-interaction-metadata-object
19+
*/
20+
export interface APIMessageInteractionMetadata {
21+
/**
22+
* ID of the interaction
23+
*/
24+
id: Snowflake;
25+
/**
26+
* Type of interaction
27+
*/
28+
type: InteractionType;
29+
/**
30+
* User who triggered the interaction
31+
*/
32+
user: APIUser;
33+
/**
34+
* IDs for installation context(s) related to an interaction. Details in Authorizing Integration Owners Object
35+
*/
36+
authorizing_integration_owners: APIAuthorizingIntegrationOwnersMap;
37+
/**
38+
* ID of the original response message, present only on follow-up messages
39+
*/
40+
original_response_message_id?: Snowflake;
41+
/**
42+
* ID of the message that contained interactive component, present only on messages created from component interactions
43+
*/
44+
interacted_message_id?: Snowflake;
45+
/**
46+
* Metadata for the interaction that was used to open the modal, present only on modal submit interactions
47+
*/
48+
triggering_interaction_metadata?: APIMessageInteractionMetadata;
49+
}
50+
1751
export type PartialAPIMessageInteractionGuildMember = Pick<
1852
APIGuildMember,
1953
| 'avatar'
@@ -122,7 +156,7 @@ export interface APIBaseInteraction<Type extends InteractionType, Data> {
122156
/**
123157
* Bitwise set of permissions the app or bot has within the channel the interaction was sent from
124158
*/
125-
app_permissions?: Permissions;
159+
app_permissions: Permissions;
126160
/**
127161
* The selected language of the invoking user
128162
*/
@@ -135,8 +169,20 @@ export interface APIBaseInteraction<Type extends InteractionType, Data> {
135169
* For monetized apps, any entitlements for the invoking user, representing access to premium SKUs
136170
*/
137171
entitlements: APIEntitlement[];
172+
/**
173+
* Mapping of installation contexts that the interaction was authorized for to related user or guild IDs.
174+
*/
175+
authorizing_integration_owners: APIAuthorizingIntegrationOwnersMap;
176+
/**
177+
* Context where the interaction was triggered from
178+
*/
179+
context?: InteractionContextType;
138180
}
139181

182+
export type APIAuthorizingIntegrationOwnersMap = {
183+
[key in ApplicationIntegrationType]?: Snowflake;
184+
};
185+
140186
export type APIDMInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
141187
Original,
142188
'guild_id' | 'member'

deno/payloads/v9/application.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import type { Permissions, Snowflake } from '../../globals.ts';
66
import type { LocalizationMap } from '../common.ts';
77
import type { APIPartialGuild } from './guild.ts';
8+
import type { ApplicationIntegrationType } from './interactions.ts';
89
import type { OAuth2Scopes } from './oauth2.ts';
910
import type { APITeam } from './teams.ts';
1011
import type { APIUser } from './user.ts';
@@ -128,6 +129,12 @@ export interface APIApplication {
128129
* Settings for the application's default in-app authorization link, if enabled
129130
*/
130131
install_params?: APIApplicationInstallParams;
132+
/**
133+
* Default scopes and permissions for each supported installation context. Value for each key is an integration type configuration object
134+
*
135+
* @unstable
136+
*/
137+
integration_types_config?: APIApplicationIntegrationTypesConfigMap;
131138
/**
132139
* The application's default custom authorization link, if enabled
133140
*/
@@ -139,6 +146,14 @@ export interface APIApplicationInstallParams {
139146
permissions: Permissions;
140147
}
141148

149+
export interface APIApplicationIntegrationTypeConfiguration {
150+
oauth2_install_params?: APIApplicationInstallParams;
151+
}
152+
153+
export type APIApplicationIntegrationTypesConfigMap = {
154+
[key in ApplicationIntegrationType]?: APIApplicationIntegrationTypeConfiguration;
155+
};
156+
142157
/**
143158
* https://discord.com/developers/docs/resources/application#application-object-application-flags
144159
*/

0 commit comments

Comments
 (0)